akhauriyash/Code-Regression huggingface dataset:
#coding: utf-8
import math

n = int(input())
pnc = list()
for i in range(n):
    pnc.append(int(input()))
maxpnc = max(pnc)

maxsieve = max(int(math.sqrt(maxpnc)), 10)
maxtemp = maxsieve + 1
maxcheck = int(math.sqrt(maxsieve))
sieve = [1 for i in range(maxtemp)]
sieve[0] = 0
sieve[1] = 0
x = 2
while x <= maxcheck:
    for i in range(2 * x, maxtemp, x):
        sieve[i] = 0
    x += 1
    while sieve[x] == 0:
        x += 1
pn = list()
for i in range(2, maxtemp):
    if sieve[i] == 1:
        pn.append(i)

ans = 0
for i in pnc:
    if i <= maxsieve:
        if i in pn:
            ans += 1
    else:
        judge = True
        for j in pn:
            if i % j == 0:
                judge = False
                break
        if judge:
            ans += 1
print(ans)


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

int gcd(int a, int b) {
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    ll res = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            for(int k = 1; k <= n; ++k) {
                int t = gcd(i, j);
                res += gcd(t, k);
            }
        }
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3648
package main

import (
	"fmt"
	"math/big"
)

func find_divisor(n int64) (bool, int64) {
	for i := int64(2); i*i <= n; i++ {
		if n%i == 0 {
			return true, i
		}
	}
	return false, 0
}

func factors(n int64) []int64 {
	var ans []int64
	r := n
	for {
		found, i := find_divisor(r)
		if found {
			ans = append(ans, i)
			r /= i
		} else {
			if r != 1 {
				ans = append(ans, r)
			}
			break
		}
	}
	return ans
}

func count(vs []int64) map[int64]int64 {
	m := make(map[int64]int64)
	for _, v := range vs {
		m[v]++
	}
	return m
}

func fact(n int64) int64 {
	if n == 1 {
		return 1
	}
	return n * fact(n-1) % 1000000007
}

func comb(a, b int64) int64 {
	var z big.Int
	z.Binomial(a, b)
	z.Mod(&z, big.NewInt(1000000007))
	return int64(z.Uint64())
}

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	fs := factors(m)
	counter := count(fs)
	var ans int64 = 1
	for _, num := range counter {
		ans = ans * comb(num+n-1, num) % 1000000007
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main() {
    int N;
    cin >> N;
    int flag = 0;
    rep(i, N) {
        int a;
        cin >> a;
        if(a%2 == 0) {
            if(a%3 == 0 || a%5 == 0){
                continue;
            } else {
                flag=1;
                out("DENIED");
                break;
            }
        }
    }
    if (!flag) out("APPROVED");
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int n,m,cnt=0,aa[220000],ans=0;
pair<int,int> pp[220000];
string s,sa[220000];
char c;
queue<int> que;
signed main(){
    cin>>n;
    rep(i,100){
        int A=i+1;
        rep(j,100){
            int B=j+1;
            rep(k,100){
                int C=k+1;
                aa[A*A+B*B+C*C+A*B+B*C+C*A]++;
            }
        }
    }
    rep(i,n){
        cout<<aa[i+1]<<endl;
    }
}

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

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

Measured memory_bytes: 256
#include <stdio.h>

#define AB (N/A+( N%A != 0 ))*B
#define CD (N/C+( N%C != 0 ))*D


int main(void) {
   int  N,A,B,C,D;
   scanf( "%d %d %d %d %d" , &N,&A,&B,&C,&D );
   printf("%d\n" , ((AB<CD)*AB+(AB>=CD)*CD));
   return 0;
}



Measured memory_bytes: 2136
#include <stdio.h>
#define N 100
#define NIL -1
void Pre(int t);
void In(int t);
void Post(int t);

typedef struct {
  int p, left, right;
}_A;
_A A[N];

int main(){
  int i, j;
  int n, id, h, d;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
   A[i].p = NIL;
   A[i].left = NIL;
   A[i].right = NIL;
  }
	
  for(i = 0; i < n; i++){
    scanf("%d %d %d", &id, &h, &d);
    A[h].p = id;
    A[d].p = id;
    A[id].left = h;
    A[id].right = d;
  }
	
  for(i = 0; i < n; i++){
    if(A[i].p == NIL) break; 
}
  printf("Preorder\n");
  Pre(i);
  printf("\n");
  printf("Inorder\n");
  In(i);
  printf("\n");
  printf("Postorder\n");
  Post(i);
  printf("\n");
	
return 0; 
}

void Pre(int t){
  printf(" %d",t);
  if(t != NIL){
    if(A[t].left != NIL) Pre(A[t].left);
    if(A[t].right != NIL) Pre(A[t].right);
  }
}

void In(int t){
  if(t != NIL){
    if(A[t].left != NIL){
      In(A[t].left);
    }
    printf(" %d",t);
    if(A[t].right != NIL){
      In(A[t].right);
} 
}
}

void Post(int t){
  if(t != NIL){
    if(A[t].left != NIL)Post(A[t].left);
    if(A[t].right != NIL)Post(A[t].right);
  }
  printf(" %d",t);
}

Measured memory_bytes: 616
#include<iostream>
using namespace std;
int main(){
 int H, W, h, w, i;
 while(1){
  cin >> H >> W;
  if( H == 0 && W == 0 )break;
  for( h = 0; h < H; h++){
   for( w = 0; w < W; w++){
    if( (h + w) % 2 == 0 ){
    cout << "#";
    }else{
    cout << ".";
    }
   }
  cout << "\n";
  }
 cout << endl;
 }
 return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1000000007)
#define MAX_N (3000)
#define MAX_M (3000)

int N, M;
ll DP[MAX_M + 1][MAX_N + 1][2];

void solve() {
  for (int j = 0; j <= N; j++)
    for (int k = 0; k < 2; k++) DP[0][j][k] = (j != 0)? k: 1 - k;
  for (int j = 0; j <= N; j++) debug_printf("%lld/%lld ", DP[0][j][0], DP[0][j][1]);
  debug_printf("\n");

  for (int i = 0; i < M; i++) {
    for (int j = 0; j <= N; j++) {
      ll d0 = 0, d1 = 0;
      if (j == 0) {
        d0 += DP[i][j][0] + DP[i][j][1] + DP[i][j + 1][0] + DP[i][j + 1][1];
      } else {
        d0 += DP[i][j - 1][0] + DP[i][j][0];
        d1 += DP[i][j - 1][1];
        if (j == 1) {
          d0 += DP[i][j][1];
        } else {
          d1 += DP[i][j][1];
        }
        if (j < N) {
          d0 += DP[i][j][0] + DP[i][j + 1][0];
          d1 += DP[i][j][1] + DP[i][j + 1][1];
        }
      }
      DP[i + 1][j][0] = d0 % INF;
      DP[i + 1][j][1] = d1 % INF;
      debug_printf("%lld/%lld ", d0, d1);
    }
    debug_printf("\n");
  }

  ll ans = 0;
  for (int j = 0; j <= N; j++) ans = (ans + DP[M][j][0]) % INF;
  printf("%lld\n", ans);
}

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

  solve();

  return 0;
}


Measured memory_bytes: 140928
import sys


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    a = [1] + list(map(int, input().split()))
    for i in range(k + 1, n + 1):
        print("Yes" if a[i] > a[i - k] else "No")


if __name__ == "__main__":
    main()


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

const int MAX = 500;
int A[MAX];
int top;

void push(int x)
{
	top++;
	A[top] = x;
}
int pop()
{
	top--;
	return A[top + 1];
}
void solve()
{
	top = 0;
        int a, b;
	char s[100];
	while(cin >> s){
		switch(s[0]){
			case '+': push(pop() + pop()); break;
			case '-': b = pop(); a = pop(); push(a - b); break;
			case '*': push(pop() * pop()); break;
			default: push(atoi(s)); break;
		}
	}
    cout << pop() << endl;
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 3088
if __name__ == '__main__':
    H, W = map(int, input().split())
    C = [str(input()) for _ in range(H)]
    C2 = [None for _ in range(2*H)]
    for i, c in enumerate(C):
        C2[2*i] = c
        C2[2*i+1] = c
    for c2 in C2:
        print(c2)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

// Dinic法により最大流問題を解く　O(EV^2)
class MaximumFlow{
	const ll INF;

	bool bfs(int s, int t){
		min_cost.assign(graph.size(),-1);
		queue<int> que;
		min_cost[s] = 0;
		que.push(s);
		while(!que.empty() && min_cost[t]==-1){
			int p = que.front();
			que.pop();
			for(auto &e:graph[p]){
				if(e.cap>0 && min_cost[e.to]==-1){
					min_cost[e.to] = min_cost[p] + 1;
					que.push(e.to);
				}
			}
		}
		return min_cost[t] != -1;
	}

	ll dfs(int idx,const int t,ll flow) {
		if(idx == t) return flow;
		for(ll &i = iter[idx];i<graph[idx].size();i++){
			edge &e = graph[idx][i];
			if(e.cap>0 && min_cost[idx]<min_cost[e.to]){
				ll d = dfs(e.to, t, min(flow, e.cap));
				if(d>0){
					e.cap -= d;
					graph[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
public:
	struct edge{
		int to;
		ll cap;
		int rev;
		bool isrev;
		int idx;
		edge()=default;
		edge(int t,ll c,int r,bool s,int i):to(t),cap(c),rev(r),isrev(s),idx(i){}
	};

	vector<vector<edge>> graph;
	vector<ll> min_cost,iter;

	MaximumFlow(int V):INF(numeric_limits<ll>::max()),graph(V){}

	void AddEdge(int from,int to,ll cap,int idx=-1){
		graph[from].emplace_back(to,cap,graph[to].size(),false,idx);
		graph[to].emplace_back(from,0,graph[from].size()-1,true,idx);
	}

	ll MaxFlow(int s,int t){
		ll flow = 0;
		while(bfs(s, t)){
			iter.assign(graph.size(), 0);
			ll f = 0;
			while((f = dfs(s, t, INF)) > 0) flow += f;
		}
		return flow;
	}
};

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

	int V=in(),E=in();
	MaximumFlow MF(V);
	REP(i,E){
		int u=in(),v=in(),C=in();
		MF.AddEdge(u,v,C);
	}
	out(MF.MaxFlow(0,V-1));
	return 0;
}



Measured memory_bytes: 3268
#include <cstdio>
 int t[3];
int main(int argc, const char * argv[]) {
  
    char s[3];
   
    scanf("%s",s);
    
    for(int i=0;i<3;i++){
        if(s[i] =='a' && t[0] ==0){
            t[0]=1;
        }
        if(s[i]=='b' && t[1] ==0){
            t[1]=1;
        }
        if(s[i]=='c' && t[2]==0){
            t[2]=1;
        }
    }
    if(t[0] && t[1] && t[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




int main()
{
    ll N;
    cin >> N;

    vector<ll> vec(N);
    ll value = 0;
    ll num = 0;
    rep(i,N){
        cin >> vec[i];
        value = max(value,vec[i]);
        if(value == vec[i]) num = i;
    }

    sort(vec.begin(),vec.end());

    rep(i,N){
        if(i == num) cout << vec[N-2] << endl;
        else cout << vec[N-1] << endl;
    }

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3200
N,M=map(int,input().split())
H=list(map(int,input().split()))
l=[[]*i for i in range(N)]
for i in range(M):
    A,B=map(int,input().split())
    l[A-1].append(B)
    l[B-1].append(A)
ans=0
for j in range(N):
    if all(H[elem-1]<H[j] for elem in l[j])==True:
        ans+=1
print(ans)







    


    














Measured memory_bytes: 29524
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, k, h[310];

    unordered_map<int, int> mp;
    unordered_map<int, int> pm;

    set<int> st;
    st.insert(0);

    cin >> n >> k;
    REP(i, n)
    {
        cin >> h[i];
        st.insert(h[i]);
    }

    int mpCnt = 0;
    for (int i : st)
    {
        mp[mpCnt] = i;
        pm[i] = mpCnt;
        mpCnt++;
    }

    ll dp[310][310][310];

    memset(dp, -1, sizeof(dp));

    dp[0][k][pm[h[0]]] = h[0];

    if (k > 0)
        dp[0][k - 1][pm[0]] = 0;

    for (int i = 0; i < n - 1; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            for (int l = 0; l < mpCnt; l++)
            {
                if (dp[i][j][l] == -1)
                    continue;

                ll val = dp[i][j][l] + max(0, h[i + 1] - mp[l]);

                if (dp[i + 1][j][pm[h[i + 1]]] == -1 || val < dp[i + 1][j][pm[h[i + 1]]])
                    dp[i + 1][j][pm[h[i + 1]]] = val;

                if (j > 0 && (dp[i + 1][j - 1][l] == -1 || dp[i][j][l] < dp[i + 1][j - 1][l]))
                    dp[i + 1][j - 1][l] = dp[i][j][l];
            }
        }
    }

    ll res = 1e18;

    for (int i = 0; i < mpCnt; i++)
        for (int j = 0; j <= k; j++)
        {
            if (dp[n - 1][j][i] != -1)
                res = min(res, dp[n - 1][j][i]);
        }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 233088
import sys



def solve(n):
    #print(n)
    NCHARS = int(26)
    MAXVAL = NCHARS
    ndigs = 1
    while n > MAXVAL:
        ndigs += 1
        n -= MAXVAL
        MAXVAL *=  NCHARS
    # now have # digs
    #print(n,ndigs,MAXVAL)
    n -= 1
    result = ''
    while n > 0:
        #print(n,MAXVAL,NCHARS)
        #MAXVAL //= NCHARS
        result += chr(n%NCHARS + ord('a'))
        n //= NCHARS
        #d = n // MAXVAL
        #d = n // MAXVAL
        #print(n,MAXVAL,result)
    if len(result) < ndigs:
        result += ''.join(['a' for i in range(ndigs-len(result))])
    print(''.join([c for c in result][::-1]))
        

        


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    n,k = [int(x) for x in IN[0].split(' ')]
    vals = [int(x) for x in IN[1].split(' ')]
    print(sum(sorted(vals)[:k]))


Measured memory_bytes: 62424
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    w = collections.Counter(list(str(input().rstrip('\n'))))
    for k, v in w.items():
        if v % 2 != 0:
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    println(problem068b(n))
}

fun problem068b(n: Int): Int {
    var max = 0
    var ans = 1
    for (i in 1..n) {
        var div = i
        var count = 0
        while (div % 2 == 0) {
            div /= 2
            count++
        }
        if (max < count) ans = i
        max = Math.max(max, count)
    }
    return ans
}

Measured memory_bytes: 31256
// B - Increment Decrement
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

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

	int x=0;
	int ans = x;
	rp(i,n){
		if(s[i]=='I'){
			x++;
		}
		else{
			x--;
		}
		ans = max(ans,x);
	}
	ote(ans);

}

Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut x = read();
    let mut a = read();
    let mut b = read();

    let ax = zet(a - x);
    let bx = zet(b - x);

    let out = stdout();
    let mut out = BufWriter::new(out.lock());

    if ax > bx {
        out.write(b"B");
    } else {
        out.write(b"A");
    }
}

fn zet(mut x: i32) -> i32 {
    if x < 0 {
        x = -x;
    }
    x
}

//fn read_v() -> Vec<char> {
//    let s = stdin();
//    //    let mut s = BufReader::new(s.lock());
//    let b = s.bytes()
//        .map(|c| c.unwrap() as char)
//        .take_while(|c| !c.is_whitespace())
//        .collect();
//    b
//}

// fn read_t() -> (u32, u32) {
//     let mut s = String::new();
//     stdin().read_line(&mut s).expect("failed read_t");
//     let mut i = s.split_whitespace().map(|c| c.parse().ok().unwrap());
//     (i.next().unwrap(), i.next().unwrap())
// }

fn read() -> i32 {
    let s = stdin();
    //    let mut s = BufReader::new(s.lock());
    let b = s.bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    b.parse().ok().expect("read() failed")
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

    int n;
    cin >> n;
    cout << (n + 1) / 2;
}


Measured memory_bytes: 3580
#include "bits/stdc++.h"
#define REP(N) for(int i=0; i<N; i++)
#define REPj(N) for(int j=0; j<N; j++)

typedef long long LL;
using namespace std;

const int MAX_ARRAY_NUM = 1e5;
LL A[MAX_ARRAY_NUM];

int main(int argc, char const *argv[])
{
    LL N;
    cin >> N;

    LL numOfNegatives = 0;
    LL numOfZeros = 0;
    LL minNumber = 1e9;
    REP(N)
    { 
        cin >> A[i];
        if(A[i] < 0) numOfNegatives++;
        if(A[i] == 0) numOfZeros++;
        if(minNumber > abs(A[i])) minNumber = abs(A[i]);
    }

    LL ans = 0;
    REP(N) { ans += abs(A[i]); }
    if(numOfZeros == 0 && (numOfNegatives%2 == 1 && numOfNegatives > 0))
    {
        ans = ans - 2 * abs(minNumber);
    }
    
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    
    long long ans = 0;
    for(int i = 1; i < n; i++)
    {
        if(arr[i] < arr[i-1])
        {
            ans += (arr[i-1] - arr[i]);
            arr[i] = arr[i-1];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4400
#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 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll N,P;
  cin >> N >> P;

  ll x = 0,y = 0;
  vector<ll> A(N);
  REP(i, N){
    cin >> A[i];
    if(A[i]%2==0){
      x++;
    }else{
      y++;
    }
  }
  
  ll a = pow(2,x);
  ll b = pow(2,y-1);
  if(y==0&&P==1){
    cout << 0 << endl;
  }else if(y==0&&P==0){
    cout << a << endl;
  }else if(x==0&&y==1&&P==0){
    cout << 0 << endl;
  }else if(x==0&&y==1&&P==1){
    cout << 1 << endl;
  }else{
    cout << a*b << endl;
  }
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main() {
  int n,cnt=0;
  long long d,x,y;
  cin>>n>>d;
  d*=d;
  for(int i=0;i<n;++i) {
    cin>>x>>y;
    if(x*x+y*y<=d)cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        var N = cin.nextInt();
        var A = cin.nextInt();
        Console.WriteLine(N * N - A);
    }


    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }
}

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

int n,i;
int a[300005];
long long ans;
int main()
{
	cin>>n;rep(i,n*3)cin>>a[i];
	sort(a+1,a+n*3+1,greater<int>());
	
	rep(i,n)ans+=a[i*2];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<long double,long double> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

struct edge { long double cost;int u, v; };
#define MAX_V 100010
int V; vector<edge> G[MAX_V];long double d[MAX_V];
void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d + V, inf*2LL);
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (int i = 0; i < G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.v] > d[v] + e.cost) {
				d[e.v] = d[v] + e.cost;
				que.push(P(d[e.v], e.v));
			}
		}
	}
}
long double dist(int x1, int y1, int r1, int x2, int y2, int r2) {
	return max(0.0, sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2)) - (r1 + r2));
}

int main() {
	int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy;
	cin >> V;
	vector<int> x(V+2), y(V+2), r(V+2);
	x[0] = sx, y[0] = sy, r[0] = 0;
	x[1] = gx, y[1] = gy, r[1] = 0;
	rep(i, 0, V) {
		cin >> x[i+2] >> y[i+2] >> r[i+2];
	}
	rep(i, 0, V + 2)rep(j,0, V + 2) {
		G[i].push_back({ dist(x[i],y[i],r[i],x[j],y[j],r[j]),i,j });
		G[j].push_back({ dist(x[i],y[i],r[i],x[j],y[j],r[j]),j,i });
	} V += 2;
	dijkstra(0);
	printf("%.12Lf", d[1]);
	return 0;
}


Measured memory_bytes: 77872
h,w,m=map(int,input().split())

r=[0]*h
c=[0]*w
s=set()
for _ in range(m):
    i,j=map(int,input().split())
    i-=1
    j-=1
    r[i]+=1
    c[j]+=1
    s.add(i*w+j)

rmx=max(r)
cmx=max(c)
rc=[i for i in range(h) if r[i]==rmx]
cc=[j for j in range(w) if c[j]==cmx]

ans=rmx+cmx-1
for i in rc:
    for j in cc:
        if i*w+j not in s:
            print(ans+1)
            exit()

print(ans)


Measured memory_bytes: 169376
n, k = map(int, input().split())

ret = 0

for b in range(k+1, n+1):
    div = n // b
    ama = n % b
    if k != 0:
        ret += div * (b - k) + max(ama - k + 1, 0)
    else:
        ret += div * (b - k) + max(ama, 0)

print(ret)


Measured memory_bytes: 2940
package main

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

func getNextLine(scanner *bufio.Reader) string {
	var buffer string
	for {
		line, isPrefix, _ := scanner.ReadLine()
		buffer += string(line)
		if isPrefix == false {
			break
		}
	}
	return buffer
}

func getIntList(scanner *bufio.Reader) []int {
	list := strings.Split(getNextLine(scanner), " ")
	l := len(list)
	result := make([]int, l)
	for i := 0; i < l; i++ {
		result[i], _ = strconv.Atoi(list[i])
	}
	return result
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewReader(fp)

	var n int
	fmt.Sscan(getNextLine(scanner), &n)

	trees := make([]tree, n+1)
	trees[0].parent = -1
	for i := 0; i < n-1; i++ {
		uvw := getIntList(scanner)
		u := uvw[0]
		v := uvw[1]
		w := uvw[2] % 2

		update(u, v, w, trees)
		trees[v].parent = u
		trees[v].w = w
	}
	for i := 1; i <= n; i++ {
		fmt.Println(chokudai(i, trees))
	}
}

type tree struct {
	parent int
	w      int
}

func update(u int, v int, w int, trees []tree) {
	p := trees[v].parent
	if p == 0 {
		return
	}
	w ^= trees[v].w
	update(u, p, w, trees)
	trees[p].parent = u
	trees[p].w = w

}
func chokudai(i int, trees []tree) int {
	if trees[i].parent == 0 {
		return trees[i].w
	}
	w := trees[i].w ^ chokudai(trees[i].parent, trees)
	trees[i].w = w
	trees[i].parent = 0
	return w
}


Measured memory_bytes: 7704
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
 
using namespace std;
 
typedef long long ll;
 
string beautify(string str) {
    string ret = "";
    for (int i = 0; i < str.size(); ++i) {
        char c = str[i];
        if ('a' <= c && c <= 'z') ret += c;
        else if ('A' <= c && c <= 'Z') ret += (char)(c-'A'+'a');
    }
    return ret;
}
 
int main() {
    string word, key; cin >> key; key = beautify(key);
    int ans = 0;
    while ( cin >> word, word != "END_OF_TEXT" ) {
//      if (word[word.size()-1] == '.') word = word.substr(0, word.size()-1);
//      if (word[0] == '\"') word = word.substr(1, word.size()-1);
//      if (word[word.size()-1] == '\"') word = word.substr(0, word.size()-1);
        word = beautify(word);
        if (word == key) {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1204
import sys
write=sys.stdout.write
while True:
	h,w=map(int,raw_input().split())
	if h==w==0: break
	for i in xrange(h):
		l=[('#' if i%2==j%2==0 else ('.' if (i%2==1 and j%2==0) or (i%2==0 and j%2==1) else '#')) for j in xrange(w)]
		for i in l:
			write(i)
		print ""
	print ""

Measured memory_bytes: 6456
// ダイクストラ
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;
const ll INF = 1e17;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<ll, ll> P;

const int N = 1e5+5;
typedef struct edge { ll to;P cost; } E;
vector<edge> G[N];// cost[u][v]は辺e=(u,v)のコスト(存在しない場合はINF)
ll en[N];       // 頂点sから両替所までの最短距離
ll sn[N];      // 頂点tから両替所までの最短距離
int n;          // 頂点数

void dijkstra_en(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(en, en+n, INF);
  en[s] = 0;
  que.push(P(0,s));

  while(!que.empty()) {
    P p = que.top();que.pop();
    ll v = p.second;
    if(en[v] < p.first) continue;
    rep(i, G[v].size()) {
      edge e = G[v][i];
      if(en[e.to] > en[v] + e.cost.first) {
        en[e.to] = en[v] + e.cost.first;
        que.push(P(en[e.to],e.to));
      }
    }
  }
}

void dijkstra_sn(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(sn, sn+n, INF);
  sn[s] = 0;
  que.push(P(0,s));

  while(!que.empty()) {
    P p = que.top();que.pop();
    ll v = p.second;
    if(sn[v] < p.first) continue;
    rep(i, G[v].size()) {
      edge e = G[v][i];
      if(sn[e.to] > sn[v] + e.cost.second) {
        sn[e.to] = sn[v] + e.cost.second;
        que.push(P(sn[e.to],e.to));
      }
    }
  }
}
ll m,a,b,c,e,s,t;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> s >> t;
  s--;t--;
  // rep(i,n) rep(j,n) cost[i][j] = INF;
  rep(i,m) {
    cin >> a >> b >> c >> e;
    a--;b--;
    E t1 = {b,P(c,e)};
    G[a].push_back(t1);
    t1 = {a,P(c,e)};
    G[b].push_back(t1);
  }
  dijkstra_en(s);
  dijkstra_sn(t);
  ll d[n];
  d[n-1] = en[n-1] + sn[n-1];
  for(int i = n-2; i>= 0; i--) {
    d[i] = min(d[i+1], en[i] + sn[i]);
  }
  // rep(i,n) cout << d[i] << endl;
  rep(i,n) {pl(1e15 - d[i]); br();}
}


Measured memory_bytes: 13228
k,n=map(int,input().split())
a_list=list(map(int,input().split()))

dmax=0
a_old=-(k-a_list[-1])
for a in a_list:
    d=a-a_old
    if d > dmax:
        dmax=d

    a_old=a

print(int(k-dmax))

Measured memory_bytes: 26444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main () {
    int n; cin >> n;
    mint a = 10, b = 9, c = 8;
    mint ans = a.pow(n) - (b.pow(n) * 2 - c.pow(n));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
#include<set>
using namespace std;


const long long int mod=1000000007;
const long long int INF=99999999999999999;



int main() {
	cout << fixed << setprecision(18);
	long long int n,p,c,now=0,sum=0,kosuu[100]={};
	cin>>n>>p;
	while(n!=0){
		now=0;
		sum=p;
		for(int i=0;i<80;i++){
			kosuu[i]=0;
		}

		while(1){
			if(sum!=0){
				kosuu[now]++;
				sum--;
			}else{
				sum+=kosuu[now];
				kosuu[now]=0;
				
			}
			if(kosuu[now]==p){
				cout<<now<<endl;
				break;
			}
			now=(now+1)%n;
		}
		
		cin>>n>>p;
	}
} 



Measured memory_bytes: 3000
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;
const int INF = 1<<28;
vector<int> road;
vector<int> dp;
int solve(int p,set<int> &same){
  if(dp[p] != -2)return dp[p];
  if(same.count(p))return -1;
  same.insert(p);
  if(road[p] == 0){
	dp[p] = p;
	return p;
  }
  return   dp[p] = solve(p+road[p],same);
}
int main(){
  int n;
  cin >> n;
  road = vector<int>(n,0);
  for(int i = 0;i < n;i++){
	cin >> road[i];
  }  
  dp = vector<int>(n,-2);
  for(int i = 0;i < n;i++){
	set<int> same;
	solve(i,same);
  }

  int res = 0;
  queue<pair<int,int> > que;
  que.push(pair<int,int>(dp[0],0));
  vector<int> used(n,INF);
  while(!que.empty()){
	pair<int,int> tmp = que.front();que.pop();
	int pos = tmp.first;
	int cnt = tmp.second;

	if(pos == n-1) {
	  cout << cnt<< endl;
	  return 0;
	}

	for(int i = 1;i <= 6;i++){
	  if(pos + i == n-1){
		cout << cnt+1 << endl;
		return 0;
	  }
	  if(dp[pos+i] != -1 && used[pos+i] > cnt+1){
		used[pos+i] = cnt+1;
		que.push(pair<int,int>(dp[pos+i],cnt+1));
	  }
	}
	
  }
  
  return 0;
}

Measured memory_bytes: 12352
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {
        var n = Console.ReadLine().ToInt32();
        var k = Console.ReadLine().ToInt32();
        var num = 1;
        for (int i = 0; i < n; i++)
        {
            num = Math.Min(num*2, num + k);
        }
        Console.WriteLine(num);
        Console.ReadLine();
        
    }


    #region ライブラリ

    #region 文字列処理

    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();

    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    #endregion
    #region DeepClone
    public static T DeepClone<T>(this T src)
    {
        using (var memoryStream = new MemoryStream())
        {
            var binaryFormatter
              = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, src);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return (T)binaryFormatter.Deserialize(memoryStream);
        }
    }
    #endregion

    public static int Gcd(int a, int b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }
    public static BigInteger Gcd(BigInteger a, BigInteger b)
    {
        if (b == 0)
            return a;
        return Gcd(b, a % b);
    }


    public static BigInteger Factorial(int n)
    {
        var dp = new BigInteger[n];
        dp[0] = 1;
        for (int i = 1; i < n; i++)
        {
            dp[i] = dp[i - 1] * (i + 1);
        }
        return dp[n - 1];
    }

    public static List<int> PrimeFactorize(int n)
    {
        var bases = n;
        var num = (int)Math.Pow(n, 0.5);
        var ls = new List<int>();
        for (int i = 2; i <= num; i++)
        {
            if (n % i == 0)
            {
                n = n / i;
                ls.Add(i);
                i--;
                continue;
            }
        }
        var nnn = 1;
        foreach (var item in ls)
        {
            nnn = nnn * item;
        }
        if (nnn != bases)
            ls.Add(n);
        return ls;
    }

    #endregion

}


Measured memory_bytes: 13140
n, k = gets.split.map(&:to_i)
v = gets.split.map(&:to_i)
op = [n, k].min
max = 0

0.upto(op) do |i|
  0.upto(op - i) do |j|
    hand = v.take(i) + v.drop(n - j)
    neg, pos = hand.sort.partition(&:negative?)
    max = [neg.drop(k - i - j).sum + pos.sum, max].max
  end
end

puts max

Measured memory_bytes: 14756
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus>=201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long M, std::vector<long long> d, std::vector<long long> c){
  ll sum=0,keta=accumulate(c.begin(),c.end(),0LL);
  REP(M){
    sum+=c[i]*d[i];
  }
  ll ans=keta-1;
  while(sum>9){
    ans+=sum/10;
    sum=sum%10+sum/10;
  }
  cout<<ans<<endl;
}

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


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
inline int re() {
	char c;
	int w=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')w=-1;
	int res = c-'0';
	while((c=getchar())>='0'&&c<='9')res = res*10+c-'0';
	return res*w;
}
const int maxn = 2e5+5,mod = 998244353;
int n,q;
long long sum[maxn];
struct Seg {
	int tag[maxn<<2];
	long long val[maxn<<2];
	inline void gtag(int x,int l,int r,int v){tag[x] = v,val[x] = (sum[r]-sum[l-1]+mod)*(v&1)%mod;}
	inline void pushdown(int x,int l,int r,int mid) {if(tag[x])gtag(x<<1,l,mid,tag[x]),gtag(x<<1|1,mid+1,r,tag[x]),tag[x] = 0;}
	inline void cover(int k,int l,int r,int x,int y,int v) {
		if(l>y||r<x)return ;
		if(l>=x&&r<=y)return gtag(k,l,r,v);
		int mid = l+r>>1;
		pushdown(k,l,r,mid);
		cover(k<<1,l,mid,x,y,v),cover(k<<1|1,mid+1,r,x,y,v);
		val[k] = (val[k<<1]+val[k<<1|1])%mod;
	}
	inline long long Count(int k,int l,int r,int x,int y) {
		if(l>y||r<x)return 0;
//		printf("%d %d %d %d %d\n",l,r,x,y,val[k]);
		if(l>=x&&r<=y)return val[k];
		int mid = l+r>>1;
		pushdown(k,l,r,mid);
		return (Count(k<<1,l,mid,x,y)+Count(k<<1|1,mid+1,r,x,y))%mod;
	}
} tr[10];
int main() {
	scanf("%d %d",&n,&q);
	long long shik = 0;
	for(int i=1; i<=n; ++i)shik = (shik*10+1)%mod,sum[i] = shik;
	tr[1].cover(1,1,n,1,n,1);
	for(int i=1,l,r,t; i<=q; ++i) {
		scanf("%d %d %d",&l,&r,&t);
		int templ = n-r+1,tempr = n-l+1;
		l = templ,r = tempr;
		for(int j=1;j<=9;++j)tr[j].cover(1,1,n,l,r,2);
		tr[t].cover(1,1,n,l,r,1);
		long long ans = 0;
		for(int j=1;j<=9;++j)
			ans = (ans+tr[j].Count(1,1,n,1,n)*j%mod)%mod;
		printf("%lld\n",ans);
	}
	return 0;
}


Measured memory_bytes: 60812
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize, k: usize,
        ns: [usize; n],
    }
    for i in 0..n - k {
        println!("{}", if ns[i] < ns[i + k] { "Yes" } else { "No" });
    }
}


Measured memory_bytes: 5576
import itertools
x=[0.]*100;y=[0.]*100
for e in iter(input,'0'):
    a=0
    n=int(e)
    for i in range(n):x[i],y[i]=map(float,input().split(','))
    for i,j in itertools.product(range(100),range(100)):
            c=0
            for k in range(n):
                if pow(x[k]-(i/10),2)+pow(y[k]-(j/10),2)<=1.01:c+=1
            if c>a:a=c
    print(a)


Measured memory_bytes: 5668
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	int x,count=0;
	cin >> x;
	for (int i = 1;; i++) {
		count += i;
		if (count >= x) {
			cout << i << endl;
			getchar();
			getchar();
			return 0;
		}
	}
}

Measured memory_bytes: 768
#include <stdio.h>
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,k;
	scanf("%d %d",&a,&b);
	scanf("%d %d",&c,&d);
	scanf("%d %d %d %d",&e,&f,&g,&h);
	i=a*e+b*f;
	j=c*e+d*f;
	if (a>=10)
	{
		k=a/10;
		i=i+k*g;
	}
	if (c>=10)
	{
		k=c/10;
		j=j+k*g;
	}
	if (b>=20)
	{
		k=b/20;
		i=i+k*h;
	}
	if (d>=20)
	{
		k=d/20;
		j=j+k*h;
	}
	if (i>j)
	{
		printf("hiroshi\n");
	}
	else if (j>i)
	{
		printf("kenjiro\n");
	}
	else if(i==j)
	{
		printf("even\n");
	}
	return 0;
}

Measured memory_bytes: 1836
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitRead();
            int A = input[0];
            int B = input[1];

            var ans = new char[100, 100];
            int x = 0;
            int y = 0;
            for(var i = 0; i < 100; i++)
            {
                for(var j = 0; j < 100; j++)
                {
                    ans[i, j] = i < 50 ? '#' : '.';
                }
            }

            for (var i = 0; i < A - 1; i++)
            {
                ans[y, x] = '.';
                nx(ref x, ref y);
            }

            x = 0;
            y = 51;
            for (var i = 0; i < B - 1; i++)
            {
                ans[y, x] = '#';
                nx(ref x, ref y);
            }


            Console.WriteLine("100 100");
            for(var i = 0; i < 100; i++)
            {
                for(var j = 0; j < 100; j++)
                {
                    Console.Write($"{ans[i, j]}");
                }
                Console.WriteLine();
            }



            

            //Console.Out.Flush();

        }

        static void nx(ref int x,ref int y)
        {
            x += 2;
            if (x >= 99) 
            {
                y += 2;
                x = 0;
            }
            return;
        }
        

    }


    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }

}


Measured memory_bytes: 13368
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  vector<vector<int>> R(D, vector<int>(10));
  for(int i = 0; i < D; i++){
    vector<pair<int, int>> v(26);
    for(int j = 0; j < 26; j++){
      v[j] = {S[i][j], j};
    }
    sort(v.rbegin(), v.rend());
    for(int j = 0; j < 10; j++){
      R[i][j] = v[j].second;
    }
  }

  random_device seed_gen;
  mt19937_64 rnd(seed_gen());
  uniform_int_distribution<int> dist_T(0, 9);

  int score = -INF;
  vector<int> ans(D);
  clock_t start = clock();
  while(true){
    int res = 0;
    vector<int> L(26, 0);
    vector<int> dp(D);
    for(int i = 0; i < D; i++){
      int T = dist_T(rnd);
      res += S[i][R[i][T]];
      L[R[i][T]] = i;
      for(int j = 0; j < 26; j++){
        res -= C[j] * (i - L[j]);
      }
      dp[i] = R[i][T]+1;
    }
    if(score < res){
      score = res;
      ans = dp;
    }

    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    if(time >= 1950) break;
    //cout << dp << " " << res << endl;
  }

  for(int p : ans){
    cout << p << endl;
  }

  return 0;
}

Measured memory_bytes: 3752
k = int(input()) + 1
gusu = []
kisu = []
for i in range(1, k):
  if i % 2 == 0:
    gusu.append(i)
  else:
    kisu.append(i)
count = 0
for i in gusu:
  for j in kisu:
    count += 1
print(count)

Measured memory_bytes: 3060