akhauriyash/Code-Regression huggingface dataset:
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif

int dx[] = {1 , 0 , -1 , 0};
int dy[] = {0 , -1 , 0 , 1};
int n , m ;
string s[21] ;
int isOk(int x, int y, int n , int m , int k){
    x += dx[k];
    y += dy[k];
    return (x >= 0 && x < n && y >= 0 && y < m && s[x][y] == '.') ;
}
int bfs(int sx, int sy){
    int gr[n][m] ;
    rep(i , n) rep(j , m){
        if(s[i][j] == '#' || (sx != i) || sy != j) gr[i][j] = inf ;
        else gr[i][j] = 0 ;
    }
    // cout << sx << " " << sy << "\n" ;
    int vis[n][m] = {} , res = 0;
    queue<pii> q; 
    q.push({sx, sy});
    while(!q.empty()){
        auto u = q.front(); 
        q.pop();
        int x = u.ff , y = u.ss ;
        res = max(res , gr[x][y]);
        if(vis[x][y]) continue ;
        vis[x][y] = true ;
        rep(k , 4){
            if(!isOk(x , y , n , m , k)) continue ;
            if(vis[x + dx[k]][y + dy[k]]) continue ;
            gr[x + dx[k]][y + dy[k]] = gr[x][y] + 1; 
            res = max(res , gr[x][y] + 1);
            q.push({x + dx[k] , y + dy[k]});
        }        
    }
    return res ;
}


void solve()
{
    cin >> n >> m ;
    int res = 0;
    rep(i , n) cin >> s[i];
    rep(i , n){
        rep(j , m){
            if(s[i][j] == '#') continue;
            res = max(res , bfs(i , j));
        }
    }
    cout << res ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

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

typedef long long ll;

using namespace std;
int main(){
	ll A, B;
	char op;
    cin >> A >> op >> B;
    ll ans;
    if (op == '+') ans = A + B;
    if (op == '-') ans = A - B;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 500001
int num;
void maxHeapify(int *,int);
void buildMaxHeap(int *);
int main(){
  int A[MAX],i;
  scanf("%d",&num);
  for(i=1;i<=num;i++)
    scanf("%d",&A[i]);
  buildMaxHeap(A);
  for(i=1;i<=num;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;
}

void maxHeapify(int A[],int i)
{
  int l,r,largest,temp;
  l = i*2;
  r = i*2+1;
  if(l<=num && A[l]>A[i])
    largest = l;
  else
    largest = i;
  if(r<=num && A[r]>A[largest])
    largest = r;

  if(largest != i) {
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
}

void buildMaxHeap(int A[])
{
  int i;
  for(i=num/2; i>=1; i--)
    maxHeapify(A,i);
}



Measured memory_bytes: 3652
h,w,x=map(int,input().split())
a=[list(input()) for i in range(h)]
ans=0
for i in range(2**(h+w)):
  b=0
  for j in range(h):
    for k in range(w):
      if (i>>j)&1==1 and (i>>k+h)&1==1 and a[j][k]=="#":
        b+=1
  if b==x:
    ans+=1    
print(ans)

Measured memory_bytes: 9124
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<stack>

using namespace std;

int main(){
  bool S[13],H[13],C[13],D[13];
  int n,i,get;
  char ch;

  cin>>n;

  for(i=0;i<13;i++){
    S[i]=0;
    H[i]=0;
    C[i]=0;
    D[i]=0;
  }

  for(i=0;i<n;i++){
    cin>>ch>>get;
    switch(ch){
      case 'S':
      S[get-1]=1;
      break;

      case 'H':
      H[get-1]=1;
      break;

      case 'C':
      C[get-1]=1;
      break;

      case 'D':
      D[get-1]=1;
      break;
    }
  }

  for(i=0;i<13;i++){
    if(S[i]==0){
      cout<<"S "<<i+1<<endl;
    }
  }

  for(i=0;i<13;i++){
    if(H[i]==0){
      cout<<"H "<<i+1<<endl;
    }
  }
  for(i=0;i<13;i++){
    if(C[i]==0){
      cout<<"C "<<i+1<<endl;
    }
  }
  for(i=0;i<13;i++){
    if(D[i]==0){
      cout<<"D "<<i+1<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
	 TreeSet<String> set;

	void Add(String a, String b){

		String s = ""+ a + b;
		set.add(s);
	}


	void run(){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		for(int i = 0; i<n; i++){
			String s = sc.next();
			set = new TreeSet<String>();

			for(int j=1; j<s.length(); j++){
				String a = s.substring(0, j);
				String aRev = new StringBuilder(a).reverse().toString();

				String b = s.substring(j, s.length());
				String bRev = new StringBuilder(b).reverse().toString();

				Add(a,b);
				Add(a,bRev);
				Add(b,a);
				Add(b,aRev);
				Add(aRev,b);
				Add(bRev,a);
				Add(aRev,bRev);
				Add(bRev,aRev);

			}

			System.out.println(set.size());
		}


	}

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

	}

}

Measured memory_bytes: 56884
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //1~nまでを並び替えた
        int[] p = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
        //規定の並び替え動作を複数回行い、12345と一致している数を最大化
        Pair[] ps = Enumerable.Repeat(0, nm[1]).Select(_ => Console.ReadLine().Split().Select(x => int.Parse(x) - 1).OrderBy(x => x).ToArray()).Select(x => new Pair(x[0], x[1])).ToArray();
        //同じグループに属している奴らは自由に並び替え可能
        //席と数字が与えられ、マッチング
        UnionFind uf = new UnionFind(nm[0]);
        foreach (var item in ps)
        {
            uf.Union(item.x, item.y);
        }
        //親,(親にひっついてる数,親達の席)
        Dictionary<int, Tuple<List<int>, List<int>>> dict = new Dictionary<int, Tuple<List<int>, List<int>>>();
        for (int i = 0; i < nm[0]; i++)
        {
            int parent = uf.Parent(i);
            if (!dict.ContainsKey(parent)) dict.Add(parent, new Tuple<List<int>, List<int>>(new List<int>(), new List<int>()));
            dict[parent].Item1.Add(p[i]);
            dict[parent].Item2.Add(i);
        }
        int count = 0;
        foreach (var item in dict.Values)
        {
            count += item.Item1.Intersect(item.Item2).Count();
        }
        Console.WriteLine(count);
    }
}


class UnionFind
{
    int[] data;
    public UnionFind(int count)
    {
        data = Enumerable.Range(0, count).ToArray();
    }
    public void Union(int x, int y)
    {
        int xp = Parent(x);
        int yp = Parent(y);
        if (xp != yp)
        {
            data[yp] = xp;
        }
    }
    public bool IsSameGroup(int x, int y) => Parent(x) == Parent(y);
    public int[] AllParents() => data.Where((x, y) => x == y).ToArray();
    public int Parent(int x)
    {
        form(x);
        return data[x];
    }
    private void form(int x)
    {
        while (data[x] != data[data[x]])
        {
            data[x] = data[data[x]];
        }
    }
}

struct Pair
{
    public int x;
    public int y;

    public Pair(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}

Measured memory_bytes: 48764
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;



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

    vector<int> h;
    for(int i = 0; i < n; ++i) {
        int buffer;
        cin>>buffer;
        h.emplace_back(buffer);
    }

    int ans = 0;
    int currentIndex = 0;

    vec end;
    for(int i = 0; i < n; ++i) {
        end.emplace_back(0);
    }

    while(1) {
        // 配列がすべて0になったら終了
        if(h == end) {
            break;
        }

        // 探索インデックスの要素が0の場合，次に進める
        if(h[currentIndex] == 0) {
            currentIndex++;
            continue;
        }

        // 探索インデックスの要素をデクリメントする
        h[currentIndex]--;
        // 最後尾なら，それより後ろの要素が無いので探索しない
        // 隣の要素が0でなければ，それもデクリメントする
        // 隣の要素が0なら，そこで探索を切る
        if(currentIndex < n-1) {
            for(int i = currentIndex+1; i < n; ++i) {
                if(h[i] != 0) h[i]--;
                else          break;
            }
        }

        // for(auto i : h) {
        //     cout << i << " ";
        // }
        // cout << endl;

        // 探索回数を1回増加
        ans++;
    }

    cout << ans;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,A,B;cin>>N>>A>>B;
    vector<int> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i];
    }
    if(N==1) cout<<abs(S[0]-B)<<endl;
    else cout<<max(abs(S[N-1]-S[N-2]),abs(S[N-1]-B))<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 1000000007;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    int n, m, i;
    cin >> n >> m;

    vector<pair<ll, ll> > arr;

    fo(i, n)
    {
        int a, b;
        cin >>a >> b;
        arr.pb(mp(a, b));
    }

    sort(all(arr));
    priority_queue<ll> pq;

    ll ans = 0;
    int nxt = 0;
    for(i = 1; i <= m; i++)
    {
        while(nxt < n && arr[nxt].first == i)
        {
            pq.push(arr[nxt].second);
            nxt++;
        }
        if(!pq.empty())
        {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4080
import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
       
        Scanner sc = new Scanner(System.in);
        int a, b, c;
        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();
        
        if( a == b ){
            System.out.println(c);
        }else if( a == c ){
            System.out.println(b);
        }else {
            System.out.println(a);
        }
    }
    
}


Measured memory_bytes: 20948
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
typedef long long LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	string S;
	cin >> S;
	int cnt = 0, ans = 0;
	rep(i, S.size()) {
		if (S[i] == 'g') {
			if (cnt > 0) {
				ans++; cnt--;
			}
			else {
				cnt++;
			}
		}
		else {
			if (cnt > 0) {
				cnt--;
			}
			else {
				ans--;
				cnt++;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
 
using namespace std;
 
int w[100];
int v[100];
long long dp[100][100001];
 
const long long infinity = 1e18;
 
int main()
{
    int n,W;
    cin>>n>>W;
    for(int i = 0;i<100;i++)
    {
        for(int j = 0;j<=100000;j++)
        {
            dp[i][j]=infinity;
        }
    }
    for(int i = 0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    dp[0][0] = 0;
    dp[0][v[0]]=w[0];
    for(int id = 1;id<n;id++)
    {
        dp[id][0] = 0;
        for(int j = 1;j<=100000;j++)
        {
            dp[id][j] = dp[id-1][j];
            if(j>=v[id])
            {
            dp[id][j] = min(dp[id][j],w[id]+dp[id-1][j-v[id]]);
            }
        }
    }
    long long answer;
    for(int val = 100000;val>=0;val--)
    {
        if(dp[n-1][val]<=W)
        {
            answer = val;
            break;
        }
    }
    cout<<answer<<endl;
    return 0;
}

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

using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int l=sqrt(n);
	long long int arr[l];
	long long int c=0;
	for(long long int i=1;i<=sqrt(n);++i){
		if(n%i==0){
			long long int s = abs(1-i)+abs(1-(n/i));
			arr[c]=s;
			c++;
		}  
	}
	sort(arr,arr+c);
	cout << arr[0] << endl;
	return 0;
}

Measured memory_bytes: 256
/*
This is code of SuperJ6 for Atcoder.
Don't copy my code during f*kin' contests.

2.71828182845904523536
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int a;
	string s;
	cin >> a >> s;
	
	if(a < 3200){
		cout << "red" << endl;	
	}else{
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  cout << (x<a ? 0 : 10) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, k;
  scanf("%d %d", &n, &k);
  int h[n];
  for(int i = 0; i < n; i++){
    scanf("%d", &h[i]);
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    ans += h[i] >= k;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        long long int N;
        long long int sum=0;
        long long int ans=0;
        cin>>N;
        if(!N)break;
        for(long long int i=0;i<N;i++){
            long long int a;
            cin>>a;
            sum+=a;
        }
        long long int pp[100000];
        long long int ppsum=0;
        for(long long int i=0;i<N-1;i++){
            cin>>pp[i];
            ppsum+=pp[i];
        }
        sort(pp,pp+N-1);
        for(long long int i=0;i<=N-1;i++){
            ans=max(ans,(i+1)*(sum+ppsum));
            //printf("[%d]=[%d]*[%d]\n",ans,i+1,sum+ppsum);
            ppsum-=pp[i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1684
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	H := sc.nextIntSlice(N)
	ans := 1
	max := H[0]
	for i := 1; i < N; i++ {
		if max <= H[i] {
			ans++
			max = H[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Main {

    /** 入力される数値の数 */
    private static final int NUMBER_OF_ELEMENT = 3;

    /** 配列がそれぞれどの辺に対応するか（X） */
    private static final int INDEX_X = 0;

    /** 配列がそれぞれどの辺に対応するか（Y） */
    private static final int INDEX_Y = 1;

    /** 配列がそれぞれどの辺に対応するか（Z） */
    private static final int INDEX_Z = 2;

    /** 出力文字列のマップ */
    private static final Map<Boolean, String> printMap = new HashMap<Boolean, String>();;
    static {
        printMap.put(true, "YES");
        printMap.put(false, "NO");
    }

    /**
     * 空白区切りの3つの数字を受け取り、
     * その3つの数字を3辺とする三角形が直角三角形であるかどうかを判定する。
     *
     * @param args
     */
    public static void main(String[] args) throws IOException {

        // 入力値を読み込む
        int[][] triangleList = readTriangleList();

        // 入力値の数だけ処理を行い、結果を出力する
        for (int i = 0; i < triangleList.length; i++) {
            boolean isTriangle = isRightTriangle(triangleList[i]);
            System.out.println(printMap.get(isTriangle));
        }

     }

    /**
     * 標準入力から空白区切りの数値を取得し、三角形を表す整数の2次元配列として返却する。
     *
     * @return 三角形を表す整数の2次元配列（3×データ数）
     */
    protected static int[][] readTriangleList() throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        // 最初にデータの個数を取得する
        int numberOfLine = Integer.parseInt(reader.readLine());

        // 1行につき、3データずつ取り込む
        int[][] triangleList = new int[numberOfLine][NUMBER_OF_ELEMENT];
        for (int i = 0; i < triangleList.length; i++) {
            String[] lengthArray = reader.readLine().split(" ");
            for (int j = 0; j < lengthArray.length; j++) {
                triangleList[i][j] = Integer.parseInt(lengthArray[j]);
            }
        }

        if (reader != null) {
            reader.close();
        }

        return triangleList;
    }

    /**
     * 指定された三角形のデータが直角三角形かどうかを判定する。
     *
     * @param triangle 三角形を表す整数配列
     * @return 直角三角形なら true、そうでないなら false
     */
    protected static boolean isRightTriangle(int[] triangle) {

        // 一番長い辺が最後にくるように配列をソートする
        Arrays.sort(triangle);

        // ピタゴラスの定理を用いて判定する
        int xx = (int)Math.pow(triangle[INDEX_X], 2);
        int yy = (int)Math.pow(triangle[INDEX_Y], 2);
        int zz = (int)Math.pow(triangle[INDEX_Z], 2);

        // x^2 + y^2 = z^2 ならば直角三角形
        return ((xx + yy) == zz);
    }
}

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

int main()
{
	int N;
	long long H;
	cin >> N >> H;
	vector<long long> a( N );
	vector<long long> b( N );
	for( int i = 0; i < N; i++ )  {
		cin >> a[i] >> b[i];
	}

	long long maxa = *max_element( a.begin(), a.end() );
	sort( b.begin(), b.end(), greater<long long>() );
	long long ans = 0;
	int i = 0;
	while( H > 0 )  {
		if( i < N && b[i] > maxa ) {
			H -= b[i];
			i++;
			ans++;
		}
		else {
			long long n = (H + maxa - 1) / maxa;
			H -= n * maxa;
			ans += n;
		}

	}

	cout << ans << endl;
}


Measured memory_bytes: 4812
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;

//最大公約数
int gcd(int a,int b){
    return b ? gcd(b,a%b):a;
}

//最小公倍数
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

//素数判定
bool isPrime(int x){
    if(x<2)return 0;
    else if(x==2)return 1;
    if(x%2==0)return 0;
    for(int i=3;i*i<=x;i+=2){
        if(x%i==0)return 0;
    }
    return 1;
}

//桁ごとの足し算
int digsum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}

//約数列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i=1;i*i<=n;++i){
        if(n%i==0){
            ret.push_back(i);
            if(i*i !=n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//累乗の計算とあまり,0で累乗そのまま出力
long long modpow(long long a,long long n,long long mod){
    if(mod==0)mod=__LONG_LONG_MAX__;
    long long res=1;
    while(n>0){
        if(n & 1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

long X;
int main(){
    cin>>X;
    if(X>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long n, std::vector<long long> a, std::vector<long long> b) {
    // check
    // cout << N << endl;
    // rep(i, N + 1) {
    //     if (i > 0) cout << " ";
    //     cout << A[i];
    // }
    // cout << endl;
    // rep(i, N) {
    //     if (i > 0) cout << " ";
    //     cout << B[i];
    // }

    int next = 0;
    ll  ans  = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] - a[i] >= 0) {
            next = b[i] - a[i];
            if (a[i + 1] > next) {
                a[i + 1] -= next;
                ans += b[i];
            } else if (a[i + 1] <= next && a[i + 1] >= 0) {
                ans += a[i] + a[i + 1];
                a[i + 1] = 0;
            } else {
                ans += b[i];
            }
        } else {
            ans += b[i];
        }
    }
    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

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


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

using namespace std;
int main()
{
    int a;
    while(~scanf("%d",&a))
    {
        if(a<105)
            printf("0\n");
        else if(a==105)
            printf("1\n");
        else
        {
            int con=1;
            for(int c=106; c<=a; c++)
            {
                if(c%2==1)
                {
                    int sum=0;
                    for(int i=1; i<sqrt(c); i++)
                    {
                        if(c%i==0)
                            sum++;
                    }
                    if(sum==4)
                        con++;
                }
            }
            printf("%d\n",con);
        }
    }
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

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

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    string S;
    cin >> S;
    if(S[2] == S[3] && S[4] == S[5]) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}



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

int main(){
  string S;
  cin >> S;
  
  char Now = S.at(0);
  int ans = 0;
  
  for (int i = 1; i < S.size(); i++){
    if (Now != S.at(i)){
      ans++;
      Now = S.at(i);
    }
  }
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int s,w;
    cin>>s>>w;
    if(s<=w) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3624
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
typedef long long LL;
const int MAXN = 200000;
const int INF = 0x3f3f3f3f;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }

  return x * w;
}

int n, q, k;
int a[MAXN + 5], tmp[MAXN + 5];
int b[MAXN + 5], c[MAXN + 5];

void init() {
  //enableFileIO();

  n = read();
  k = read();
  q = read();
  for (int i = 1; i <= n; ++i) tmp[i] = a[i] = read(); 
}

inline int calc(int mn) {
  int tot = 0, l = 1, r = 1;
  while (l <= n) {
    while (a[l] < mn && l <= n) ++l;
    r = l;
    while (a[r] >= mn && r <= n) ++r;
    
    int len = 0;
    for (int i = l; i < r; ++i) b[++len] = a[i];
    if (len >= k) {
      sort(b + 1, b + 1 + len);
      for (int i = 1; i <= len - k + 1; ++i) c[++tot] = b[i];
    }
    l = r;
  }

  sort(c + 1, c + 1 + tot);
  if (tot >= q) {
    return c[q] - c[1];
  } else {
    return INF;
  }
}

int main() {
  init();

  sort(tmp + 1, tmp + 1 + n);
  int ans = INF;
  for (int i = 1; i <= n; ++i) {
    ans = min(ans, calc(tmp[i]));
  }

  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define tc ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))
#define all(v) v.begin(),v.end()

struct cmp {
    bool operator() (ll a,ll b){
        return a < b;
    }
};

/*ll modp(ll a,ll p,ll n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    ll e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1)
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}

ll modInverse(ll n, ll p)
{
    return modp(n, p, p-2);
}
 
ll nCrModPFermat(ll n, ll r,ll p)
{
   // Base case
   if (r==0)
      return 1;
    
    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    ll fac[n+1];
    fac[0] = 1;
    for (ll i=1 ; i<=n; i++)
        fac[i] = fac[i-1]*i%p;
  
    return (fac[n]* modInverse(fac[r], p) % p *
            modInverse(fac[n-r], p) % p) % p;
}*/

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    string s; cin>>s;
    cout<<s;
    if(s[s.size()-1] == 's') cout<<"es";
    else cout<<"s";
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


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

int main()
{
    int K, S;
    int ans = 0;
    cin >> K >> S;
    for (int i = 0; i <= K; i++)
    {
        for (int j = 0; j <= K; j++)
        {
            int z = S - i - j;
            if (0 <= z && z <= K)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
c = list(map(int, input().split()))
MOD = 10 ** 9 + 7

c = sorted(c)
nokori = n - 1
ans = 0
ptn = (pow(2, n, MOD) ** 2) * pow(2, MOD - 2, MOD) % MOD
for i, val in enumerate(c):
    ans += (ptn * val) + (ptn * nokori * val * pow(2, MOD - 2, MOD))
    ans %= MOD
    nokori -= 1

print(ans % MOD)


Measured memory_bytes: 89164
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int w,h;
    cin >> w >> h;

    while(w!=0 && h!=0) {
        int tn[w][h];
        int te[w][h];
        int dn[w][h];
        int de[w][h];

        for(int i=1; i<w; ++i) {
            tn[i][0]=0;
            te[i][0]=0;
            dn[i][0]=0;
            de[i][0]=1;
        }
        for(int i=1; i<h; ++i) {
            tn[0][i]=0;
            te[0][i]=0;
            dn[0][i]=1;
            de[0][i]=0;
        }

        for(int i=1; i<w; ++i) {
            for(int j=1; j<h; ++j) {
                tn[i][j]=de[i][j-1]%100000;
                te[i][j]=dn[i-1][j]%100000;
                dn[i][j]=(tn[i][j-1]+dn[i][j-1])%100000;
                de[i][j]=(te[i-1][j]+de[i-1][j])%100000;
            }
        }

        cout << (tn[w-1][h-1]+te[w-1][h-1]+dn[w-1][h-1]+de[w-1][h-1])%100000 << endl;

        cin >> w >> h;
    }
    return 0;
}

Measured memory_bytes: 3256
#include<stdio.h>

int main()
{
     int h,m,s;
     int S;
     scanf("%d\n",&S);
     h = S/3600;
     m = S%3600/60;
     s = S%3600%60;
     printf("%d:%d:%d\n",h,m,s);
     return 0;
}


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

#define pb push_back

using namespace std;

typedef long long ll;

const int maxn=1e3+10;

int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    bool sw=false;
    for(int i=s.length()-1 ; i>=0 ; i--)
    {
        string k;
        int mark=0;
        if(i-4<0)
        {
            sw=true;
            break;
        }
        for(int j=i-4 ; j<i+1 ; j++)
            k+=s[j];
        if(k=="erase" || k=="dream")
        {
            mark=1;
            i-=4;
        }
        if(!mark)
        {
            if(i-5<0)
            {
                sw=true;
                break;
            }
            k="";
            for(int j=i-5 ; j<i+1 ; j++)
                k+=s[j];
            if(k=="eraser")
            {
                mark=1;
                i-=5;
            }
            if(!mark)
            {
                if(i-6<0)
                {
                    sw=true;
                    break;
                }
                k="";
                for(int j=i-6 ; j<i+1 ; j++)
                    k+=s[j];
                if(k=="dreamer")
                {
                    mark=1;
                    i-=6;
                }
                if(!mark)
                    sw=true;
            }
        }
    }
    if(sw)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <set>
#include <unordered_map>
#include <iomanip>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int c = -1;
    int f = -1;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='C') c= i;
        else if(s[i] == 'F') f=i;
    }
    if(c!=-1 && f!=-1) {
        if(c < f) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else 
        cout << "No" << endl;
}


Measured memory_bytes: 384
N = int(input())

A = list(map(int, input().split()))
mod = 10**9 + 7

s = sum(A) % mod
s += mod
ss = 0
for i in range(N):
    ss += A[i]**2 % mod

ss = ss % mod
if (s**2 - ss) % 2 == 1:
    ss -= mod

print((((s**2) - ss) // 2) % mod)

Measured memory_bytes: 31748
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
//#include<bits/extc++.h> inavilable in dev-cpp
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define me(i,k) memset(i,k,sizeof(i))
#define fr1(a,n) for(int a=1;a<=(n);a++)
#define frab(i,a,b) for(int i=(a);i<(b);i++)
#define fr0(i,n) for(int i=0;i<(n);i++)
#define trav(a,n) for(auto& a : n)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const ll modn=1000000007;

int main(){
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	frab(x,k+1,n+1)
	{
		ll f=n/x;
		ll num=x-k;
		ans+=num*f;
		ll sur=n%x+1;
		ans+=max(sur-k,0LL);
	}
	if(k==0)ans=n*n;
	cout<<ans<<'\n';
	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,x;
  cin >> n >> x;
  ll d = 0;
  ll ans = 1;
  REP(i,n){
    ll l;
    cin >> l;
    d += l;
    if(d<=x) ans++;
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),M=sc.nextInt(),i,j,k,l;
		String[] a=new String[N],b=new String[M];
		boolean f=true;
		for(i=0;i<N;i++){
			a[i]=sc.next();
		}
		for(i=0;i<M;i++){
			b[i]=sc.next();
		}
		for(i=0;i<N-M+1;i++){
			for(j=0;j<N-M+1;j++){
				for(k=0;k<M;k++){
					for(l=0;l<M;l++){
						if(a[i+k].charAt(j+l)!=b[k].charAt(l)){
							f=false;
							break;
						}
					}
				}
				if(f==true){
					System.out.println("Yes");
					System.exit(0);;
				}
				f=true;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
using namespace std;
int main(){
	vector<int> A;
	int n,a,x,p;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a==0){
			cin>>x;
			A.push_back(x);
		}else if(a==1){
			cin>>p;
			cout<<A[p]<<endl;
		}else if(a==2){
			A.pop_back();
		}
	}

	return 0;
}



Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int n ,m;
    cin >> n >> m;
    vector<vector<int>> miti(n);
    vector<int> ans(n,-1);
    queue<int> que;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        miti[a].push_back(b);
        miti[b].push_back(a);
    }
    que.push(0);
    ans[0] = 0;
    while(!que.empty()){
        int q = que.front();
        que.pop();
        REP(i,miti[q].size()){
            if(ans[miti[q][i]] == -1){
                que.push(miti[q][i]);
                ans[miti[q][i]] = q;
            }
        }
    }
    REP(i,n){
        if(ans[i] == -1){
            No();
            return 0;
        }
    }
    Yes();
    FOR(i,1,n){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

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


int main()
{
  int X,X_02,tmp;
  bool flag=false;
  
  cin>>X;
  X_02=pow((double)X,1.0/5.0)*2;
  for(int i=0;i<X_02;i++)
  {
    for(int j=0;j<X_02;j++)
    {
      tmp=i*i*i*i*i-j*j*j*j*j;
      if(tmp==X)
      {
        cout<<i<<" "<<j;
        flag=true;
        break;
      }
      
      tmp=i*i*i*i*i+j*j*j*j*j;
      if(tmp==X)
      {
        cout<<i<<" "<<(-1)*j;
        flag=true;
        break;
      }
    }
    if(flag)
      break;
  }
}

Measured memory_bytes: 3556
#include<stdio.h>
#define N 100
int main(){
  int n,i,j,k,u,v;
  int A[N][N];
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
    }
  }
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j) printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int M;
  cin >> M;

  int sum = 0;
  int keta = 0;
  int d, c;
  REP(i, M){
    cin >> d >> c;
    sum += d*c;
    keta += c;
  }

  cout << keta-1+(sum-1)/9 << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 10
int main(){
    int x = 0;
    scanf("%d",&x);
    if(x==1){
        printf("0");
    }else{
        printf("1");
    }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

vi v;

int main() {
  int n;
  S(n);
  rep(i,0,n) {
    int x;
    S(x);
    v.pb(x);
  }
  sort(all(v));
  int g = 0;
  rep(i,0,n) {
    int diff = 0;
    if(!i || v[i] != v[i - 1]) {
      diff = v[i] - (i?v[i - 1]:0);
    }
    if(diff & 1) {
      g ^= n - i;
    }
  }
  if(g) printf("first\n");
  else printf("second\n");
  return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    int ans = 0;
    int cnt = 1;
    int a = 0;
    int pre_a = 0;
    rep(i, n) {
        pre_a = a;
        cin >> a;
        if ( i == 0 ) continue;
        if ( a == pre_a ) ++cnt;
        else {
            ans += cnt / 2;
            cnt = 1;
        }
        if ( i == n - 1 ) {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, x;
    int tallGate[100] = {0};

    cin >> n >> m >> x;

    for (int i = 0; i < m; i++) {
        int tmp;
        cin >> tmp;
        tallGate[tmp] = 1;
    }

    int count1 = 0;
    int count2 = 0;
    for (int i = x; i < n; i++) {
        if (tallGate[i] == 1) count1++;
    }
    for (int i = x; i >= 0; i--) {
        if (tallGate[i] == 1) count2++;
    }
    int count = min(count1, count2);

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int n,q;
int A[21];

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()
{	
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> A[i];
	cin >> q;
	int a;
	for(int i=0;i<q;i++)
	{
		cin >> a;
		if(solve(0,a))
			cout << "yes\n";
		else
			cout << "no\n"; 
	}
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const double EPS  = 1e-10;
const bool debug = 0;
//---------------------------//

int N;
vector<int> g[112345];
int a[112345], cnt[112345];

int main(){
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	REP(i, N) {
		int v = (i + a[i]) % N;
		g[i].push_back(v);
		cnt[v]++;
	}
	
	queue<int> que;
	REP(i, N) if (cnt[i] == 0) que.push(i);
	
	int ans = N;
	while (!que.empty()) {
		int u = que.front();
		que.pop();
		
		ans--;
		
		REP(i, g[u].size()) if (--cnt[g[u][i]] == 0) que.push(g[u][i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 9792
from itertools import combinations
import numpy as np
        #買う本
N, M, X = map(int, input().split())
items   = np.array([list(map(int, input().split())) for _ in range(N)], dtype=np.int32)
all_book= [i for i in range(N)]  
out     = 10**18
flag    =False
price_list  =[]
#for c in itertools.product([False, True], repeat=N):
for num in range(1,N+1): #1冊からN冊まで
    for t in combinations(all_book,num): #参考書を買う組合せ、全列挙
        book_buy        =np.array(t,dtype=int) 
        understand_now  = items[book_buy] 
        tmp             = np.sum(understand_now, axis=0)
        if np.all(tmp[1:] >= X):
            #out = min(out, tmp[0])
            price_list.append(np.sum(tmp[0]))
            flag =True
if flag ==True:
    print(min(price_list))
else:
    print(-1)

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

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};

//aを0とする

int kuniku(int i,int j){
    return 500005*i+j;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    BinaryIndexedTree< int > bit(500005*31);
    for(int i=1;i<=n;i++){
        int c=s[i-1]-'a';
        bit.add(kuniku(c,i),1);
    }
    int q; cin >> q;
    for(int i=0;i<q;i++){
        int t,j; cin >> t >> j; 
        if(t==1){
            char c; cin >> c;
            bit.add(kuniku(s[j-1]-'a',j),-1);
            bit.add(kuniku(c-'a',j),1);
            s[j-1]=c;
            //cout << s << endl;
        }else if(t==2){
            int c;cin >> c;
            int ans=0;
            for(int i=0;i<30;i++){
                if(bit.sum(kuniku(i,c))-bit.sum(kuniku(i,j-1))>0) ans++; 
            }
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 61444
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N;
    cin >> K;
    vector<int> x(N);
    int sum = 0;
    for(int i = 0;i < N;i++){
        cin >> x.at(i);
        if(K - x.at(i) <= x.at(i)){
          sum += (K - x.at(i)) * 2;
        }
        else{
            sum += x.at(i) * 2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256