akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;


int main () {

  ll N;
  cin >> N;
  vector<string> S;
  string temp;
  REP(i, 0, N) {
    cin >> temp;
    S.push_back(temp);
  }

  ll max_count = 0;
  map<string, int> mp;
  REP(i, 0, N) {
    auto itr = mp.find(S[i]);
    if ( itr != mp.end() ) { // has S[xyz]
      mp[S[i]] = mp[S[i]] + 1;
      if (mp[S[i]] > max_count) {
        max_count = mp[S[i]];
      }
    }
    else {
      mp[S[i]] = 0;
    }
  }

  vector<string> ans;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if (itr->second == max_count) {
      ans.push_back(itr->first);
    }
  }
  sort(ans.begin(), ans.end());

  // ans
  // cout << "--------" << endl; // debug
  for(auto itr = ans.begin(); itr != ans.end(); ++itr) {
    cout << (*itr) << endl;
  }

  return 0;
}


Measured memory_bytes: 30320
#include <iostream>

using namespace std;

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

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

    int min = 9999999;
    for (int i = 0; i < n - 1; i++)
    {
        int s = 0;
        for (int j = 0; j <= i; j++)
        {
            s+= w[j];
        }

        int t = 0;
        for (int k = i + 1; k < n; k++)
        {
            t+= w[k];
        }
        
        if (abs(s-t) < min)
        {
            min = abs(s - t);
        }
    }

    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {

		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			int input = sc.nextInt();
			a[i] = input;
		}

		Arrays.sort(a);

		for (int i = 0; i < n; i++) {
			if (i != n - 1 && (a[i] == a[i + 1])) {
				System.out.println("NO");
				return;
			}
		}

		System.out.println("YES");
	}
}


Measured memory_bytes: 64372
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	set<string> ss;
	while(n--) {
		string s;
		cin >> s;
		ss.insert(s);
	}	
	cout << ss.size() << endl;
	
}





Measured memory_bytes: 19236
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

ll dp[11][156][22];
int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		int n, K, s; scanf("%d %d %d", &n, &K, &s); if (n == 0 && K == 0 && s == 0) break;
		for (int i = 0; i <= 10; i++)for (int j = 0; j <= 155; j++) for (int k = 0; k <= 21; k++) dp[i][j][k] = 0;
		dp[0][0][n + 1] = 1;
		for (int i = 0; i < K; i++) {
			for (int j = 0; j <= 155; j++) {
				for (int k = 1; k <= n + 1; k++) {
					if (dp[i][j][k] == 0) continue;
					if (k == n + 1 && i != 0) continue;
					for (int l = 1; l < k; l++) {
						if (j + l <= 155) {
							dp[i + 1][j + l][l] += dp[i][j][k];
						}
					}
				}
			}
		}
		ll res = 0;
		for (int i = 0; i <= n; i++) res += dp[K][s][i];
		cout << res << "\n";
	}
	return 0;

}



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

N, M = map(int, input().split())

men = N*M

if N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(men - 2)
else:
    print(men - (N*2 + M*2 - 4))


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

using namespace std;

int main(){
	long long x;
	cin>>x;
	double n=100;

	long long ans=0;

	while(n<x){
		ans++;
		n=floor(n*1.01);
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;
constexpr int MAX_N = 200000;

ll N;
ll A[MAX_N];

ll S[MAX_N+1];
std::vector<ll> vs;
std::set<ll> uS;

ll tri[MAX_N+1];

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", A+i );

  S[0] = 0;
  vs.push_back( S[0] );
  uS.insert( S[0] );
  rep( i, N )
  {
    S[i+1] = S[i]+A[i];
    vs.push_back( S[i+1] );
    uS.insert( S[i+1] );
  }

  std::sort( vs.begin(), vs.end() );
  //rep( i, N+1 )
    //printf( "%d%c", vs[i], i==N?'\n':' ' );

  tri[0] = 0;
  rep( i, N )
    tri[i+1] = tri[i]+i+1;

  ll ans = 0;
  for( auto it = uS.begin(); it != uS.end(); ++it )
  {
    //printf( "%d\n", *it );
    ans += tri[std::upper_bound( vs.begin(), vs.end(), *it )-std::lower_bound( vs.begin(), vs.end(), *it )-1];
  }

  printf( "%lld\n", ans );

  return 0;
}

Measured memory_bytes: 15856
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

int main(void){
  int n,k;
  cin >> n >> k;
  double p = 0.0;
  for(int i = 1;i <= n;++i){
    int cnt = i;
    ll calc = 1;
    while(cnt < k){
      cnt *= 2;
      calc *= 2;
    }
    p += 1.0 / (calc * n);
  }
  cout << setprecision(15) << p << endl;
  return 0;
}


Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll c=0;
	while(n--){
		ll x;
		cin>>x;
		if(x>=k){
			c++;
		}
	}
	cout<<c;
}

Measured memory_bytes: 256
import java.io.*;
        import java.math.BigDecimal;
        import java.math.BigInteger;
        import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        String str = in.next();
        int[] rem = new int[2019];
        long l = 0;
        for (int i = 0; i < str.length(); i++) {
            rem[0]++;
            int[] next = new int[2019];
            int n = str.charAt(i) - '0';
            for (int j = 0; j < 2019; j++) if (rem[0] != 0) {
                int k = (j * 10 + n) % 2019;
                if (k == 0) l += rem[j];
                next[k] += rem[j];
            }
            rem = next;
        }
        out.println(l);
        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}

Measured memory_bytes: 53028
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int main(){
    int n;cin>>n;
    VEC(int,a,n);
    int c = 0;
    int res = 1;
    rep(i,n-1){
        if(c==0){
            if(a[i]<a[i+1])c = 1;
            else if(a[i]>a[i+1])c = 2;
            else c = 0;
            continue;
        }
        if(c==1){
            if(a[i]>a[i+1]){
                res++;
                c = 0;
            }
        }
        if(c==2){
            if(a[i]<a[i+1]){
                res++;
                c = 0;
            }
        }
    }
    cout<<res<<endl;
}



Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrrr
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            if (N == 25)
            {
                Console.WriteLine("Christmas");
            }else if(N == 24)
            {
                Console.WriteLine("Christmas Eve");
            }else if(N == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }else if (N == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }

            
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <math.h>



int main(){

    int x, y;   //x:匹, y:本
    int t, k, n;

    scanf("%d %d", &x, &y);

    //i:鶴数
    for(int i=0; i<=x; i++){

        //鶴をi匹とした場合の亀数
        n = x - i;
        
        if( (i*2) + (n*4) == y ){ printf("Yes\n"); return 0; }
    }
    printf("No\n");

    return 0;
}

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

// templates -------------------------------------

#define ULL unsigned long long
#define LL long long
#define LLD long long double
#define REP(i, n) for(LL i = 0; i < n; i++)
#define INV_REP(i, n) for(LL i = n; 0 <= i; i--)

LL combination(LL n, LL m)
{
  LL nume = 1;
  REP(i, m) nume *= (n-i);
  LL demo = 1;
  for(int i = 1; i <= m; i++) demo *= i;
  return nume / demo;
}

template<class T>
class UnionFind
{
private:
  vector<T> par;
  vector<T> rank;
  vector<T> size;

public:
  UnionFind(T N) :
    par(N, T()), rank(N, T()), size(N, T())
  {
    REP(i, N)
    {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

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

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

  inline T getSize(T x)
  {
    return size[root(x)];
  }

  void unite(T x, T y)
  {
    T r1 = root(x);
    T r2 = root(y);
    if(r1 == r2) return;

    if(rank[r1] < rank[r2]) swap(r1, r2);
    if(rank[r1] == rank[r2]) rank[r1]++;
    par[r2] = r1;
    size[r1] += size[r2];
  }
};

// --------------------------------------

LL n, m;
vector<LL> a;
vector<pair<LL, LL>> bc;

void input()
{
  cin >> n >> m;
  a.resize(n);
  bc.resize(m);
  for(int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for(int i = 0; i < m; i++)
  {
    cin >> bc[i].first >> bc[i].second;
  }
}

void solve()
{
  sort(bc.begin(), bc.end(), [](const auto& a, const auto& b){return a.second > b.second;});
  sort(a.begin(), a.end());

  LL ai = 0;
  for(LL i = 0; i < m; i++)
  {
    if(bc[i].second <= a[ai]) break;

    for(LL j = 0; j < bc[i].first; j++)
    {
      if(bc[i].second <= a[ai]) break;
      a[ai] = bc[i].second;
      ai++;
    }
  }

  cout << accumulate(a.begin(), a.end(), 0LL);
}

int main()
{
  input();
  solve();
  return 0;
}

Measured memory_bytes: 2688
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline

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

    MOD = 10 ** 9 + 7

    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]


    def cmb(n, k, p):
        if (k < 0) or (n < k):
            return 0
        r = min(k, n - k)
        return fact[n] * factinv[k] * factinv[n - k] % p


    for i in range(2, N + 1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)


    ans = pow(10, N, MOD)
    ans -= pow(8, N, MOD)
    ans %= MOD
    for i in range(1, N + 1):
        ans -= pow(8, N - i, MOD) * cmb(N, i, MOD) * 2
        ans %= MOD
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 165512
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for _ in range(A)] + [INF]
t = [-INF] + [int(input()) for _ in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    # upper_boundを使う
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b-1], s[b]]:  # xを挟んで左側と右側
        for T in [t[d-1], t[d]]:  # xを挟んで右側と左側
            d1, d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(S-T)  # 神社行って寺行くのと, 寺行って神社行く, の2通り
            res = min(res, d1, d2)
    print(res)


Measured memory_bytes: 12800
X,K,D = map(int,input().split())
m = 0
s = 0
X = abs(X)
if X >= K * D:
    m = X - (K * abs(D))
else:
    l = X // D
    K -= l
    X -= l * D
    m = X
    if K % 2 == 1:
        X -= D
        m = X
       


       

print(abs(m))

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> AC(n, 0), WA(n, 0);
    int ans_ac, ans_wa;
    ans_ac = ans_wa = 0;
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        p--;
        if (s == "WA") WA[p]++;
        else if (AC[p]==0) {
            AC[p]++;
            ans_ac++;
            ans_wa += WA[p];
        }
    }
    cout << ans_ac << " " << ans_wa << endl;
    return 0;
}

Measured memory_bytes: 1024
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 105,MaxV = 100005;
int n,w,cost[MaxN],value[MaxN];
long long dp[MaxV];
int main(){
	IOS
	while(cin>>n>>w){
		int tot_value=0;
		for(int i=0 ; i<n ; i++){
			cin>>cost[i]>>value[i];
			tot_value+=value[i];
		}
		for(int i=1 ; i<=tot_value ; i++){
			dp[i] = INT_MAX;
		}
		for(int i=0 ; i<n ; i++){
			for(int j=tot_value ; j>0 ; j--){
				if(j-value[i]<0)
					continue;
				dp[j]=min(dp[j], dp[j-value[i]]+cost[i]);
			}
		}
		int ans=0;
		for(int i=0 ; i<=tot_value ; i++){
			if(dp[i]<=w)
				ans=max(ans, i);
		}
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 4432
N, K = map(int, input().split())
L = list(map(int, input().split()))
L.sort()
s = len(L)
L_dif = [[i,L[i+1]-L[i]] for i in range(s-1)]
L_dmax = L_dif.copy()
L_dmax.sort(key=lambda tup: tup[1:], reverse=True)
size = L[K-1]-L[0]
piv = min(K,N)
rem_dif = [L_dmax[i][1] for i in range(piv-1)]
ans = size - sum(rem_dif)
print(ans)

Measured memory_bytes: 31792
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[] input;
	static int pos;

	public static void main(String[] arg) {
		String[] q = sc.nextLine().split("\\.");
		StringBuilder sb = new StringBuilder();
		while (sc.hasNext()) {
			sb.append(sc.nextLine() + "\n");
		}
		input = sb.toString().toCharArray();
		Elem elem = parseMapping(0);
		for (int i = 1; i < q.length && elem != null; ++i) {
			elem = elem.get(q[i]);
		}
		System.out.println(elem == null ? "no such property" : elem.toString());
	}

	static Mapping parseMapping(int indent) {
		Mapping mapping = new Mapping();
		while (true) {
			int n = nextIndent();
			if (n != indent) break;
			pos += indent;
			int sp = pos;
			while (input[pos] != ':') {
				++pos;
			}
			String key = String.valueOf(input, sp, pos - sp);
			++pos;
			if (input[pos] == '\n') {
				++pos;
				int m = nextIndent();
				Mapping child = parseMapping(m);
				mapping.map.put(key, child);
			} else {
				++pos;
				sp = pos;
				while (input[pos] != '\n') {
					++pos;
				}
				mapping.map.put(key, new Str(String.valueOf(input, sp, pos - sp)));
				++pos;
			}
		}
		return mapping;
	}

	static int nextIndent() {
		int cur = pos;
		if (cur >= input.length) return -1;
		while (input[cur] == ' ') {
			++cur;
		}
		return cur - pos;
	}

	static abstract class Elem {
		abstract Elem get(String key);
	}

	static class Mapping extends Elem {
		HashMap<String, Elem> map = new HashMap<String, Elem>();

		Elem get(String key) {
			return map.get(key);
		}

		public String toString() {
			return "object";
		}

		void print(int indent) {
			for (String key : map.keySet()) {
				for (int i = 0; i < indent; ++i) {
					System.out.print(" ");
				}
				System.out.print(key + ":");
				Elem obj = map.get(key);
				if (obj instanceof Mapping) {
					System.out.println();
					((Mapping) obj).print(indent + 1);
				} else {
					System.out.println(((Str) obj).v);
				}
			}
		}

	}

	static class Str extends Elem {
		String v;

		Str(String s) {
			this.v = s;
		}

		Elem get(String key) {
			return null;
		}

		public String toString() {
			return "string \"" + v + "\"";
		}
	}

}

Measured memory_bytes: 27892
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ll long long
using namespace std;
string ans,s,t;
int arr[3000][3000];
void fun(int i,int j)
{
    //cout<<ans<<"\n"
    if(i<0 || j<0)
     return;
    if(s[i]==t[j])
    {
        ans+=s[i];
        fun(i-1,j-1);
    }
    else
    {
        if(i-1>=0 && j-1>=0 && arr[i-1][j]>arr[i][j-1])
        {
            fun(i-1,j);
        }
        else if(j-1>=0)
        {
            fun(i,j-1);
        }
        else
        {
            fun(i-1,j);
        }
    }
}
int main()
{
    int n1,n2,i,j;
    cin>>s>>t;
    n1=s.size();n2=t.size();
    if(s[0]==t[0])
     arr[0][0]=1;
    else
     arr[0][0]=0;
    for(i=1;i<n2;i++)
    {
        if(s[0]==t[i])
         arr[0][i]=1;
        else
         arr[0][i]=arr[0][i-1];
    }
    for(i=1;i<n1;i++)
    {
        if(s[i]==t[0])
         arr[i][0]=1;
        else
         arr[i][0]=arr[i-1][0];
    }
    for(i=1;i<n1;i++)
    {
        for(j=1;j<n2;j++)
        {
            if(s[i]==t[j])
             arr[i][j]=arr[i-1][j-1]+1;
            else
             arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
        }
    }
    /*cout<<s<<" "<<t<<"\n";
    for(i=0;i<n1;i++)
    {
        for(j=0;j<n2;j++)
         cout<<arr[i][j]<<" ";
        cout<<"\n";
    }*/
    //int ans=arr[n1-1][n2-1];
    //ans=arr[n1-1][n2-1];
    fun(n1-1,n2-1);
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

Measured memory_bytes: 35584
#include <stdio.h>
#include <math.h>

int isPrime(int L){
  int i = 3;
  int Ls = sqrt(L);
  if (!(L%2)){
      return 0;
  }
  while (i <= Ls){
    if(!(L%i)){
       return 0;
    }
    i += 2;
  }
  return 1;
}

int main() {

  int n, i, c=0, num;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d", &num);
    if(num==2) c++;
    c += isPrime(num);
  }

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

  return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long  n;
    cin>>n;
    long long  heal;
    cin>>heal;
    vector<pair<long long ,long long >> vec;
    for(int i=0;i<n;i++)
    {
        long long x,y;
        cin>>x>>y;
        vec.push_back(make_pair(y,x));
    }

    long long  mx=0;
    for(int i=0;i<vec.size();i++)
    {
        if(vec[i].second>mx)
            mx=vec[i].second;
    }

    sort(vec.begin(),vec.end(),greater<pair<long long ,long long >>());
    long long  sum=0,ans=0;

    for(int i=0;i<n;i++)
    {
        if(vec[i].first<=mx)
            break;
        sum+=vec[i].first;
        ans++;
        //cout<<ans;
        if(sum>=heal)
            break;
    }
    if(sum>=heal)
    {

        cout<<ans;
        //return 0;
    }
    else
    {
        heal-=sum;
    //cout<<mx;

        if(heal%mx!=0)
        {
   cout<<ans+(heal/mx)+1;
        }
        else
            cout<<ans+(heal/mx);
    }

}

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

int n,l,a[100010],ta,mu;

signed main(){
	cin>>n>>l;
	cin>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
		if(ta<a[i-1]+a[i]){
			ta=a[i]+a[i-1];
			mu=i;
		}
	}
	if(ta<l){
		cout<<"Impossible"<<endl;
		ggr
	}
	else{
		cout<<"Possible"<<endl;
	}
	for(int i=1;i<mu;i++)cout<<i<<endl;
	for(int i=n-1;i>=mu+1;i--)cout<<i<<endl;
	cout<<mu<<endl;
	ggr
}


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

double EPS = 1e6;
class P{
public:
    int x, y;
    P(){};
    P(int x, int y): x(x), y(y){};
    
    bool operator < (const P &r)const{
        return 0 < x*r.y - y*r.x;
    }
    bool operator == (const P &r)const{
        return 0 == x*r.y - y*r.x;
    }
};

typedef pair<P, P> Span;

int H, W;
vector<string> field;

//up, down, right, left
int dh[] = {1, -1, 0, 0};
int dw[] = {0, 0, 1, -1};

Span make_span(double h, double w, int dir){
    P l, r;
    if(dir == 0){ //up
        l = P(w+1, h+1);
        r = P(w, h+1);
    }
    if(dir == 1){ //down
        l = P(w+1, h);
        r = P(w, h);
    }
    if(dir == 2){ //right
        l = P(w+1, h);
        r = P(w+1, h+1);
    }
    if(dir == 3){ //left
        l = P(w, h);
        r = P(w, h+1);
    }
    return Span(l, r);
}

int main(){
    cin >> H >> W;
    field.resize(H+1);
    for(int i=0; i<W+1; i++)
        field[H] += '.';
    
    for(int i=0; i<H; i++){
        cin >> field[H-1-i];
        field[H-1-i] += '.';
    }
    
    vector<Span> spans; //??????
    for(int h=0; h<H; h++){
        for(int w=0; w<W; w++) if(field[h][w] == '#'){
            for(int i=0; i<4; i++){
                int nh = h + dh[i];
                int nw = w + dw[i];
                if(nh<0 || nw<0 || H<nh || W<nw || field[nh][nw]!='.') continue;
                
                spans.push_back(make_span(h, w, i));
            }
        }
    }
    vector<P> tmp;
    for(auto span: spans)
        tmp.push_back(span.first), tmp.push_back(span.second);
    sort(tmp.begin(), tmp.end());
    tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());

    vector<int> cum(tmp.size());
    for(auto &span: spans){
        int l = lower_bound(tmp.begin(), tmp.end(), span.first) - tmp.begin();
        int r = lower_bound(tmp.begin(), tmp.end(), span.second) - tmp.begin();
        cum[l]++; cum[r]--;
    }
    int ans = 0;
    for(int i=0; i<cum.size(); i++){
        if(i != 0) cum[i] += cum[i-1];
        ans = max(ans, cum[i]);
    }
    if(field[0][0] == '#')
        ans++;
    cout << ans/2 + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 21316
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		for(int i = 0; i < count; i++){
			double[][] data = new double[2][2];
			for(int k = 0; k < data.length; k++){
				double x0 = sc.nextDouble();
				double y0 = sc.nextDouble();
				data[k][0] = sc.nextDouble() - x0;
				data[k][1] = sc.nextDouble() - y0;
			}
			data[0][1] *= data[1][0];
			data[1][1] *= data[0][0];
			String s = (data[0][1] == data[1][1]) ?
					"YES" : "NO" ;
			System.out.println(s);
		}
		sc.close();
	}
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll H; cin >> H;
    ll cnt=0;
    while(H>0){H/=2; ++cnt;}
    cout << (1LL<<cnt)-1 << endl;
}

Measured memory_bytes: 256
n,m = [int(x) for x in input().split()]
ab = []
for _ in range(n):
    a,b = [int(x) for x in input().split()]
    ab.append([a,b])

sorted_ab = sorted(ab, key=lambda x: x[0])

price = 0
for i in range(n):
    if m > sorted_ab[i][1]:
        price += sorted_ab[i][0] * sorted_ab[i][1]
        m -= sorted_ab[i][1]
    else:
        price += m * sorted_ab[i][0]
        break

print(price)

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

vector<vector<int>> edge(100'000);
vector<int> ranks(100'000, 0);
vector<int> num(100'000, 0);
vector<int> parent(100'000, 0);
vector<bool> visited(100'000, false);

int dfs(int u){
    visited[u] = true;
    int tmp = 1;
    for (int i = 0; i < edge[u].size(); i++){
        if (visited[edge[u][i]]) continue;
        ranks[edge[u][i]] = ranks[u] + 1;
        parent[edge[u][i]] = u;
        tmp += dfs(edge[u][i]);
    }
    num[u] = tmp;
    return tmp;
}

int main(){
    int n;
    cin >> n;
    int a, b;
    for (int i = 1; i < n; i++){
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    dfs(0);
    int g = (ranks[n - 1] + 2) / 2;
    int s = n - 1;
    while (ranks[s] > g) s = parent[s];
    if (num[s] * 2 >= n) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
}

Measured memory_bytes: 13184
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstring>/*The header <string> and
<string.h> does not contain the useful
function 'memset' and 'memcpy'.*/
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<utility>
#include<algorithm>
#include<functional>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<cstdio>
using namespace std;
long long x[1005][3],N,M,mx;
int main()
{
	cin>>N>>M;
	for(int i=1;i<=N;i++)
		for(int j=0;j<3;j++)
			cin>>x[i][j];
	for(int mask=0;mask<8;mask++)
	{
		vector<long long> all;
		for(int i=1;i<=N;i++)
		{
			int t=mask;
			long long cur=0;
			for(int j=0;j<3;j++)
			{
				if(t&1)
					cur+=x[i][j];
				else	cur-=x[i][j];
				t/=2;
			}
			all.push_back(cur);
		}
		sort(all.rbegin(),all.rend());
		long long cur=0;
		for(int i=0;i<M;i++)
			cur+=all[i];
		mx=max(mx,cur);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

ll gcd ( ll a, ll b ) { return __gcd ( a, b ); }
ll lcm ( ll a, ll b ) { return a * ( b / gcd ( a, b ) ); }

const int mx = 10;
char c[mx][mx], tmp[mx][mx];

inline bool checkBit(ll n, int i) { return n&(1LL<<i); }
inline ll setBit(ll n, int i) { return n|(1LL<<i); }
inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); }

int main()
{
    optimize();

    int n, m, k, ans = 0;
    cin >> n >> m >> k;
    for ( int i = 0; i < n; i++ ) {
        for ( int j = 0; j < m; j++ ) cin >> c[i][j];
    }


    for ( int mask1 = 0; mask1 < ( 1 << n ); mask1++ ) {
        for ( int mask2 = 0; mask2 < ( 1 << m ); mask2++ ) {
            for ( int i = 0; i < n; i++ ) {
                for ( int j = 0; j < m; j++ ) tmp[i][j] = c[i][j];
            }

            for ( int i = 0; i < n; i++ ) {
                if ( checkBit( mask1, i ) ) {
                    for ( int j = 0; j < m; j++ ) tmp[i][j] = '.';
                }
            }

            for ( int i = 0; i < m; i++ ) {
                if ( checkBit( mask2, i ) ) {
                    for ( int j = 0; j < n; j++ ) tmp[j][i] = '.';
                }
            }

            int cnt = 0;
            for ( int i = 0; i < n; i++ ) {
                for ( int j = 0; j < m; j++ ) {
                    if ( tmp[i][j] == '#' ) cnt++;
                }
            }

            if ( cnt == k ) ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


















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

using namespace std;

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

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

    vector<long long> m(n, 0);
    for (int i = 0; i < n; i++) {
        if (i + a[i] < n) {
            m[i + a[i]]++;
        }
    }

    long long res = 0;
    for (int i = 0; i < n; i++) {
        if (i - a[i] >= 0) {
            res += m[i - a[i]];
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 5628
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

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

int main()
{
        //input->compute->output//

        int N, D;
        cin >> N >> D;

        vector<vector<int>> vec(N, vector<int>(D));

        for (int i = 0; i < N; i++)
        {
                for (int j = 0; j < D; j++)
                {

                        cin >> vec[i][j];
                }
        }
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
                for (int j = i + 1; j < N; j++)
                {
                        double dis = 0;
                        for (int k = 0; k < D; k++)
                        {
                                dis += (vec[i][k] - vec[j][k]) * (vec[i][k] - vec[j][k]);
                        }
                        debug(dis);
                        double s = pow(dis, 0.5);
                        if ((int)s == s)
                        {
                                ans++;
                        }
                }
        }

        cout << ans << endl;

        return 0;
}


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

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

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

    int total=0;
    int max=-1;
    for(int i=0; i<n; i++){
        if(max<=h[i]){
            max=h[i];
            total++;
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

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


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {
   int a,b,c;
   
   scanf("%d %d %d",&a,&b,&c);
   
    if (a<b && b<c)
    {
    	printf("Yes\n");
    }
    
    else 
    {
    	printf("No\n");
    }
    
	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
#define ll long long int

int main() {
	ll n;
	cin >> n;
	vector<ll>l(n);
	rep(i,n){
		cin >> l[i];
	}
	ll count = 0;
	ll x = 0;
	rep(i,n){
		rep(j,n){
			if(i < j && l[i] != l[j]){
				rep(k,n){
					if(i < k && j < k && l[i] != l[k] && l[k] != l[j]){
						x = max({l[i],l[j],l[k]});
						if(l[i]+l[j]+l[k] - 2 * x > 0){
							count++;
						}
					}
				}
			}
		}
	}
	cout << count;
	return 0;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }

int H, W;


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

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

    cin >> H >> W;
    vector<string> maze(H);
    rep(i, H) cin >> maze[i];
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            rep(k, H) {
                rep(l, W) {
                    if (maze[i][j] == '#' || maze[k][l] == '#') continue;
                    if (i == k && j == l) continue;
                    vector<vector<int>> dist(H, vector<int>(W, -1));
                    dist[i][j] = 0;
                    queue<P> que;
                    que.push(P{i, j});
                    while (!que.empty())
                    {
                        P cp = que.front();
                        int x = cp.first;
                        int y = cp.second;
                        que.pop();

                        rep(i, 4)
                        {
                            int nx = x + dx[i];
                            int ny = y + dy[i];
                            if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                                continue;
                            if (maze[nx][ny] == '#')
                                continue;

                            if (dist[nx][ny] == -1)
                            {
                                que.push(P{nx, ny});
                                dist[nx][ny] = dist[x][y] + 1;
                            }
                        }
                    }
                    ans = max(ans, dist[k][l]);
                    
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int fibonacci(int);

int data[45];

int main(){
    int n,i;

    scanf("%d",&n);
    for(i=0;i<45;i++){
        data[i] = -1;
    }
    printf("%d\n",fibonacci(n));

    return 0;
}
int fibonacci(int n){

    if(n==0 || n==1){
        return data[n] = 1;
    }
    if(data[n] != -1){
        return data[n];
    }
    
    return data[n] = fibonacci(n-2) + fibonacci(n-1);
}


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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int cand = sc.nextInt();
			int no = cand % 39;
			if(no == 0) no = 39;
			if(no < 10){
				System.out.println("3C0"+no);
			}else {
				System.out.println("3C"+no);
			}
		}
		sc.close();
	}
}

Measured memory_bytes: 17232
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    long double rab = sqrtl((long double)a * b);
    
    if (a + 2*rab + b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int h, w, n; cin >> w >> h >> n;
  vvi v(h);
  //vector<string> grid(h);
  /*
  REP(i, h) {
    REP(j, w) {
      grid[i].push_back('.');
    }
  }
  */

  REP(i, n) {
    int x, y; cin >> y >> x;
    x--; y--;
    //grid[x][y] = '#';
    v[x].push_back(y);
  }
  REP(i, h) {
    if(SZ(v[i]) != 0) sort(ALL(v[i]));
  }
  /*
  REP(i, h) {
    REP(j, w) {
      cout << grid[i][j];
    }
    cout << endl;
  }
  */


  if(n == 0) {
    cout << w << endl;
    return 0;
  }

  int pos = SZ(v[0]) == 0 || v[0][0] != 1;
  int prev = (SZ(v[0]) == 0 ? w : v[0][0]);
  set<int> cand;
  cand.insert(prev);
  FOR(i, 1, h) {
    int nxt = w;
    bool end = false;
    REP(j, SZ(v[i])) {
      if(v[i][j] == pos) {
        if (pos == prev - 1) {
          end = true;
          break;
        } else {
          pos++;
        }
      } else if(v[i][j] == pos + 1) {
        nxt = pos + 1;
        end = true;
        break;
      } else if(v[i][j] > pos) {
        nxt = v[i][j];
        break;
      }
    }
    //cout << i << ":" << pos << ":" << nxt << endl;
    cand.insert(nxt);
    if(end) {
      break;
    }
    prev = nxt;
    pos++;
  }

  cout << *(cand.begin()) << endl;

}























Measured memory_bytes: 9728
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define N 100050
int n,m,b[N],l[N],r[N],i,j;
long long c[N],d[N];
int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d%d%d",&b[i],&l[i],&r[i]);
	long long tot1=0;
	for (i=1;i<=n;i++) tot1+=1LL*b[i]*l[i],c[i]=1LL*b[i]*l[i]+1LL*(m-b[i])*r[i];
	sort(c+1,c+n+1);d[n+1]=N;
	for (i=n;i>=1;i--){
		d[i]=c[i];c[i]+=c[i+1];
		if (c[i]>=tot1) break;
	}long long ans=1LL*m*(n-i),ans2=m,psz;i++;
	for (j=1;j<=n;j++) if (1LL*b[j]*l[j]+1LL*(m-b[j])*r[j]>=d[i]){if (tot1+1LL*(m-b[j])*r[j]-c[i-1]>=0) psz=ceil(((double)tot1+1LL*(m-b[j])*r[j]-c[i-1])/r[j])+b[j],ans2=min(ans2,psz);
	else psz=ceil(((double)tot1+1LL*b[j]*l[j]+1LL*(m-b[j])*r[j]-c[i-1])/l[j]),ans2=min(ans2,psz);}
	else{if (tot1-1LL*b[j]*l[j]-c[i]>=0) psz=ceil(((double)tot1-1LL*b[j]*l[j]-c[i])/r[j])+b[j],ans2=min(ans2,psz);
	else psz=ceil(((double)tot1-c[i])/l[j]),ans2=min(ans2,psz);}
	printf("%lld\n",ans+ans2);
	return 0;
}

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

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define step(i, f, n, a) for(int (i) = (f); (i) < (n); (i)+=a)
#define rstep(i, f, n, a) for(int (i) = (f); (i) >= (n); (i)-=a)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

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

ll a[100000];

ll calc(ll start, ll n){
  ll sum = start, result = 0;
  for (ll i = 1; i < n; i++) {
    if (sum > 0) {
      sum += a[i];
      if (sum >= 0) {
        result += sum+1;
        sum = -1;
      }
    }else{
      sum += a[i];
      if (0 >= sum) {
        result += (sum-1)*(-1);
        sum = 1;
      }
    }
    // cout << sum << result << a[i] << endl;
  }
  return result;
}


int main(){
  ll n, ans;
  gets(n)
  for (ll i = 0; i < n; i++) {
    gets(a[i])
  }
  if (a[0] > 0) {
    ans = min(calc(a[0],n),calc(-1,n)+a[0]+1);
    // puts(calc(a[0],n))
  }else if (a[0] < 0) {
    ans = min(calc(a[0],n),(calc(1,n)+((a[0]-1)*(-1))) );
  }else{
    ans = min(calc(1,n)+1,calc(-1,n)+1 );
  }
  puts(ans)
}


Measured memory_bytes: 1024
#include <stdio.h>
#define MMAX 10
typedef long long ll;
ll gcd(ll a, ll b);
ll extgcd(ll a, ll b, ll *x, ll *y);
ll mod_inverse(ll a, ll m);
int linear_congruence(int *a, int *b, int *m, ll *x, ll *mod, int msize);
int main(void)
{
  int i, j, n, m, d, lflag, a[MMAX], b[MMAX], mod[MMAX], t[MMAX];
  scanf("%d %d %d", &n, &m, &d);
  for (i = 0; i < m; i++) scanf("%d", &t[i]);
  for (i = 0; i < d; i++) {
    ll x = 0, mode = 1;
    for (j = 0; j < m; j++) {
      scanf("%d", &b[j]);
      if (b[j] == -1) {
        a[j] = b[j] = 0;
        mod[j] = 1;
      } else {
        a[j] = 1;
        mod[j] = t[j];
      }
    }
    lflag = linear_congruence(a, b, mod, &x, &mode, m);
    if (!lflag) break;
    if (mode > n) {
      if (x > n) {
        lflag = 0;
        break;
      }
      n = x;
    } else {
      x += ((n - x) / mode) * mode;
      n = x;
    }
  }
  if (lflag) printf ("%d\n", n);
  else printf("-1\n");
}

ll gcd(ll a, ll b)
{
  if (b == 0LL) return a;
  else gcd(b, a % b);
}

ll extgcd(ll a, ll b, ll *x, ll *y)
{
  ll d = a;
  if (b != 0LL) {
    d = extgcd(b, a % b, y, x);
    *y -= (a / b) * (*x);
  } else {
    *x = 1LL;
    *y = 0LL;
  }
  return d;
}

ll mod_inverse(ll a, ll m)
{
  ll x, y;
  extgcd(a, m, &x, &y);
  return (x % m + m) % m;
}

int linear_congruence(int *a, int *b, int *m, ll *x, ll *mod, int msize)
{
  int i;
  for (i = 0; i < msize; i++) {
    ll a2 = a[i] * (*mod), b2 = b[i] - a[i] * (*x), d = gcd(m[i], a2), t;
    if (b2 % d != 0LL) return 0;
    t = b2 / d * mod_inverse(a2 / d, m[i] / d) % (m[i] / d);
    *x += (*mod) * t;
    *mod *= m[i] / d;
  }
  *x = ((*x)  + (*mod)) % (*mod);
  return 1;
}


Measured memory_bytes: 2056
n = input()
s = input()

li = list(s)

x = 0
num_list = list()
num_list.append(0)
for argv in li:
	if argv == "I":
		x += 1
		num_list.append(x)
	elif argv == "D":
		x -= 1
		num_list.append(x)


print(max(num_list))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = Integer.MAX_VALUE;
		for (int i = 1; i <= n / 2; i++) {
		    min = Math.min(min, getSum(i) + getSum(n - i));
		}
	    System.out.println(min);
	}
	
	static int getSum(int x) {
	    int sum = 0;
	    while (x > 0) {
	        sum += x % 10;
	        x /= 10;
	    }
	    return sum;
	}
}
	


Measured memory_bytes: 22868