akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")  
#include<bits/stdc++.h>
using namespace std;

#define ll 				long long
#define eb 				emplace_back
const long long 		MOD = 1e9 + 7;
#define rep(i,n) 		for (int (i) = 0; (i) < (n); (i)++) 
#define REP(i,k,n)  	for (int (i) = (k); (i) <= (n); (i)++) 
#define REPR(i,k,n) 	for (int (i) = (k); (i) >= (n); (i)--)
#define watch(x) 		cout << (#x) << " = " << (x) << endl
#define t(x)			int x; cin >> x; while(x--)

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	/*---- continue Coding ;----*/

	ll int n, m;
	cin >> n >> m;
	ll int a[m], ans = 0;
	rep(i, m){
		cin >> a[i];
		ans+=a[i];
	}
	if((n-ans) >= 0){
		cout << n-ans << "\n";
	}else{
		cout << -1 << "\n";
	}
	
	/*---- break ;----*/

	cerr<<"Execution time: "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0;
}

Measured memory_bytes: 3852
import math
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
primes = primes(10**5)
dp = [0]*(10**5+1)
cnt = 0
for i in range(1, 10**5+1, 2):
    if i in primes:
        if (i+1)//2 in primes:
            cnt += 1
    dp[i] = cnt

    
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(dp[r]-dp[l-2])
    

Measured memory_bytes: 52384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>

int main(){
  cout << fixed << setprecision(10);
  long double n,k;
  cin >> n >> k;
  int count = 0;
  long double ans = 0;
  for(int i = 1;i<=n;i++){
    long double sum = 1/n;
    int a = i;
    while(a < k){
      a *= 2;
      sum *= 0.5;
      //cout << sum << endl;
    }
    ans += sum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int DP[3001][3001]={{0}};
int main(){
    string s, t;
    cin >> s >> t;
    for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++){
            if(s[i]==t[j]) DP[i+1][j+1] = DP[i][j]+1;
            else DP[i+1][j+1] = max(DP[i+1][j], DP[i][j+1]);
        }
    }
    //cout << DP[s.size()][t.size()] << endl;
    int i=s.size();
    int j=t.size();
    int count=0;
    string res = "";
    while(DP[i][j]!=0){
        while(DP[i][j]==DP[i][j-1]||DP[i][j]==DP[i-1][j]){
            while(DP[i][j]==DP[i][j-1]){
                j--;
            }
            while(DP[i][j]==DP[i-1][j]){
                i--;
            }
        }
        count++;
        i--;
        j--;
        res = s[i] + res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int n, x[55], y[55], t;
map<pair<int, int>, int> dif;
int main(){
    scanf("%d", &n);
    rep(i,n) scanf("%d%d", x+i, y+i);
    rep(i,n) rep(j,n) if(i!=j) dif[make_pair(x[i]-x[j],y[i]-y[j])]++;
    for(auto it: dif) t = max(t, it.second);
    printf("%d\n", n-t);
}

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

int main() {

  int a, b;
  cin >> a >> b;
  if (a >= b) {
    for (int i = 0; i < a; i++) {
      cout << b;
    }
    cout << endl;
  }
  else {
    for (int i = 0; i < b; i++) {
      cout << a;
    }
    cout << endl;
  }
  

}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    long int K,N;
    cin>>K>>N;
    vector<long int> A;
    long A_;
    for(int i=0;i<N;i++){

        cin>>A_;
        A.push_back(A_);
    }
    std::sort(A.begin(),A.end());
    int diff=0;
    int num;
    for(int i=0;i<N;i++){
        if(i>=N-1){
            int tmp=K-A[i];
            if(diff<tmp+A[0]){
                diff=tmp+A[0];
                num=i;
            }
        }else{
            if(diff<A[i+1]-A[i]){
                diff=A[i+1]-A[i];
                num=i;
            }
        }

    }

    long int result=K-diff;
    cout<<result;


}

Measured memory_bytes: 2420
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readLine()!!.split(" ").map { it.toInt() }
    val plus = aa.mapIndexed { idx, i -> idx + i }.groupBy { it }
    val minus = aa.mapIndexed { idx, i -> idx - i }.groupBy { it }

    var cnt = 0L

    plus.entries.forEach {
        val p1 = it.value.size
        val p2 = minus[it.key]?.size ?: 0
        cnt += p1.toLong() * p2.toLong()
    }

    println(cnt)
}

Measured memory_bytes: 112052
#include <vector>
#include <map>
#include <iostream>

using namespace std;
/** Problem0062 : Rank Checker **/
int main()
{
	map<int, vector<int> > num;
	
	int t1, t2, rank; char c;
	while (1) {
		cin >> t1 >> c >> t2;
		if (t1 == 0 && t2 == 0) break;
		num[t2].push_back(t1);
	}
	
	while (cin >> t1) {
		map<int, vector<int> >::iterator it = num.begin();
		for (; it != num.end(); it++) {
			vector<int> v = num[it->first];
			vector<int>::iterator it2 = v.begin();
			for (;it2 != v.end(); it2++) {
				if (*it2 == t1) {
					rank=0;
				}
			}
			rank++;
		}
		cout << rank << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
#include<stdio.h>

typedef struct{
  int p;
  int color;
} Ver;

int min(int a,int b){
  if(a > b) return b;
  else return a;
}

int main(){
  int n,i,j,m;
  int direction,parent,sum = 0;

  scanf("%d",&n);
  int M[n+1][n+1];
  Ver G[n+1];

  for(i = 1;i <= n;i++){
    G[i].color = 0;
    for(j = 1;j <= n;j++){
      scanf("%d",&M[i][j]);
    }
  }

  G[1].color = 1;

  while(1){
    m = 2001;
    direction = 0;
    for(i = 1;i <= n;i++){
      if(G[i].color == 1){
        for(j = 1;j <= n;j++){
          if(M[i][j] != -1 && G[j].color == 0){
            if(m > M[i][j]){
              m = M[i][j];
              parent = i;
              direction = j;
            }
          }
        }
      }
    }
    G[direction].color = 1;
    G[direction].p = parent;
    if(m == 2001) break;
  }

  for(i = 1;i <= n;i++){
    if(G[i].color == 1){
      for(j = 1;j <= n;j++){
        if(M[i][j] != -1 && G[j].color == 1 && G[j].p == i){
          sum += M[i][j];
        }
      }
    }
  }
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
ll lcm(int a, int b) {
	return 1ll *  a / __gcd(a, b) * b;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b;
	cin >> a >> b;
	cout << lcm(a, b) << '\n';
	return 0;
}


Measured memory_bytes: 256
N = int(input())  # 数値入力
H = list(map(int, input().split()))  # リスト入力（数値）  map関数はリストの各要素に対して関数を適用してくれる

ans = 0
while sum(H) != 0:
    i = 0
    while(i < N):
        if(H[i] == 0):
            i += 1
        else:
            ans += 1
            while((i < N) and (H[i] > 0)):
                H[i] -= 1
                i += 1

print(ans)


Measured memory_bytes: 2940
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			System.out.println((a< b && b < c) ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 26120
def mpower(a, b, n):
    if b==0:
        return 1
    if b==1:
        return a%n
    a1=a
    k=1
    while a1<n and k<b:
        a1=a1*a
        k=k+1

    a1=a1%n
    b1=b//k
    a2=a
    b2=b%k
    return (mpower(a1,b1,n)*mpower(a2,b2,n))%n

m = 10**9+7
n = int(input())

print((mpower(10,n,m) + (m - mpower(9,n,m))*2 + mpower(8,n,m))%m)


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

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

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

  int counter;
  for (int i=0; i<1000000; i++) {
    int j = i % n;
    if (array[j] == 0) break;
    if (array[j] % 2 == 0) {
      int tmp = array[j] / 2;
      ++counter; array[j] = tmp;
    } else {
      break;
    }
  }
  cout << counter / n << endl;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;
const int maxN = 200 * 1000 + 9;

int n;
int a[maxN], f[maxN];

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

	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	
	for(int i = n; i > 0; i--){
		int sum = 0;
		for(int j = i + i; j <= n; j += i){
			sum += f[j];
		}

		sum %= 2;
		if(a[i] != sum){
			f[i] = 1;
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		ans += (f[i] > 0);
	}

	cout << ans << '\n';

	for(int i = 1; i <= n; i++){
		if(f[i]){
			cout << i << '\n';
		}
	}

	return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>

using namespace std;

int main(){
    int H,W;
    cin>>H>>W;
    int A[501][501];
    vector<int> ans;
    for(int h=1;h<=H;h++){
        for(int w=1;w<=W;w++){
            cin>>A[h][w];
        }
    }
    for(int h=1;h<H;h++){
        for(int w=1;w<=W;w++){
            if(A[h][w]%2==1){
                ans.push_back(h);
                ans.push_back(w);
                ans.push_back(h+1);
                ans.push_back(w);
                A[h][w]--;
                A[h+1][w]++;
            }
        }
    }
    for(int w=1;w<W;w++){
        if(A[H][w]%2==1){
            ans.push_back(H);
            ans.push_back(w);
            ans.push_back(H);
            ans.push_back(w+1);
            A[H][w]--;
            A[H][w+1]++;
        }
    }
    cout<<ans.size()/4<<endl;
    for(int i=0;i<ans.size();i+=4){
        cout<<ans[i]<<' '<<ans[i+1]<<' '<<ans[i+2]<<' '<<ans[i+3]<<endl;
    }
    return 0;
}


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

ans = 0

if N == 1:
    print(1)
    exit()
if N == 2:
    print(5)
    exit()
if N == 3:
    print(11)
    exit()

for i in range(1, N//2+2):
    last = N//i
    ans += ((1+last) * last // 2 * i)

ans += (N//2+2 + N) * (N - N//2 - 1) // 2

print(ans)

Measured memory_bytes: 9188
using System;

class C
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		long k = h[0], a = h[1], b = h[2];

		if (a + 2 < b)
		{
			var c = 1L;
			var d1 = Math.Min(k, a - 1);
			k -= d1;
			c += d1;
			if (k == 0) { Console.WriteLine(c); return; }

			c += k / 2 * (b - a);
			k %= 2;
			Console.WriteLine(c + k);
		}
		else
		{
			Console.WriteLine(k + 1);
		}
	}
}


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

int N;
int a[100010];

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

    sort(a, a + N);

    int cnt = 0;
    for (int i = 0; i < N;)
    {
        int x = a[i];
        int c = 0;
        while(a[i]== x && i<N){
            i++;
            c++;
        }
        cnt += c%2;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 640
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    A.append(x)

    A = sorted(A)

    if N == 1:
        print(A[1] - A[0])
        exit()

    g = 1
    g = gcd(A[1] - A[0], A[2] - A[1])
    for i in range(1, len(A)):
        g = gcd(g, A[i] - A[i - 1])
            
    print(g)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n);
    vector<ll> a(n),b(n),sumv(n);
    ll x,sum=0;
    in(a);
    sort(all(a));
    rep(i,n){
        sum+=a[i];
        sumv[i]=sum;
    }
    sort(rall(a));
    sort(rall(sumv));
    int i=1;
    for(i=1;i<n;i++){
        if(a[i-1]>2*sumv[i])break;
    }
    out(i);
}

Measured memory_bytes: 5604
#include<iostream>
        #include<vector>
        using namespace std;
         
        int main()
        {
        int n,t,sum=0;
          cin>>n;
          vector<int> tnk;
          for(int i=0;i<n;i++)
          {
          cin>>t;
          tnk.push_back(t);
          }
          for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++)
            {
            sum+=tnk[i]*tnk[j];
            }}
          cout<<sum;
          return 0;
        }


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
sp = [0]*n
for i in range(n):
    s, p = map(str, input().split())
    p = int(p)
    sp[i] = [i+1, s, p]
sp.sort(key=lambda x:(x[1],-x[2]))
for _ in sp:
    print(_[0])

Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        char carr1[]=br.readLine().toCharArray();
        char carr2[]=br.readLine().toCharArray();
        int cntr=0;
        for(int i=0;i<carr1.length;i++)
        {
            if(carr1[i]!=carr2[i])
            cntr++;
        }
        pw.println(cntr);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 38124
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define mod 1000000007
#define F first
#define S second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;

ll modexp(ll a, ll b)
{
	a %= mod; // a should not be divisible by mod 
	if(a <= 1)
		return a;
	if(b == 0)
		return 1;
	if(b % 2 == 0)
	{
		ll res = modexp(a, b / 2);
		return (res * res) % mod;
	}
	return (a * modexp(a, b - 1)) % mod;
}
const int N = 1e6 + 5;
int main()
{
	sync;
		
	ll n;
	cin >> n;
	ll ans = modexp(10, n) + modexp(8, n) - 2 * modexp(9, n) + 2 * mod;
	cout << ans % mod;
}

Measured memory_bytes: 3608
import sys

N,x=map(int,input().split())
A=list(map(int,input().split()))
A.sort()

S=[None]*N
S[0]=A[0]

if A[0]>x:
    print(0)
    sys.exit()

for i in range(1,N):
    S[i]=S[i-1]+A[i]
    if S[i]>x:
        break

if S[i]==x:
    print(N)
else:
    print(i)


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

public class Main {

  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int noOfItems = in.nextInt();
    int W = in.nextInt();
    Item[] items = new Item[noOfItems + 1];
    items[0] = new Item(0, 0);
    for (int k = 0; k < noOfItems; k++) {
      items[k + 1] = new Item(in.nextInt(), in.nextInt());
    }
    //Arrays.sort(items);
    long[][] dp = new long[items.length][W + 1];
    for (int i = 0; i < dp.length; i++) {
      dp[i][0] = 0;
    }
    for (int j = 0; j < dp[0].length; j++) {
      dp[0][j] = 0;
    }

    for (int i = 1; i < dp.length; i++) {
      for (int j = 1; j < dp[0].length; j++) {
        if (items[i].weight > j) {
          dp[i][j] = dp[i - 1][j];
        } else {
          long secWeight = 0;
          if (j - items[i].weight > 0) {
            secWeight = dp[i - 1][j - items[i].weight];
          }
          dp[i][j] = Math.max(dp[i - 1][j], items[i].price + secWeight);
        }
      }
    }
    System.out.println(dp[items.length - 1][W]);
    in.close();
  }

  static class Item implements Comparable<Item> {
    int weight;
    int price;

    public Item(int w, int p) {
      this.weight = w;
      this.price = p;
    }

    public int compareTo(Item t) {
      return this.weight - t.weight;
    }
  }
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
using T = pair<i64, P>;
const i64 M = 1000000007;
i64 d[10][10];
signed main() {
  i64 n;
  cin >> n;
  for (i64 i = 1; i <= n; i++) {
    string s = to_string(i);
    char l = s[s.size() - 1];
    if (1 <= l) {
      d[s[0] - '0'][l - '0']++;
    }
  }
  i64 c = 0;
  for (i64 a = 1; a <= 9; a++) for (i64 b = 1; b <= 9; b++) {
    c += d[a][b] * d[b][a];
  }
  cout << c << endl;
}


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

ans = 0
pre_i = 100
for p in range(n):
  i = a[p]
  ans += b[i-1]
  if i >= 2 and pre_i+1 == i:
    ans += c[pre_i-1]
  pre_i = i
print(ans)
  


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int sy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

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

ll solve(ll a) {
	ll sum = 1;
	for (int i = 2; i <= a; i++) {
		sum *= i;
		sum %= atcoder;
	}
	return sum;
}

int main(){

	int a, b;
	ll suma = 0, sumb = 0;
	cin >> a >> b;
	if (abs(a - b) >1)pr(0);
	else if(abs(a-b) == 1) {
		pr(solve(a)*solve(b)%atcoder);
	}
	else {
		pr(solve(a)*solve(b)*2%atcoder);
	}
	//system("pause");
	return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c ;
    int counter = 0;
    int ans =0;
    for(int i=0;i<s.length();i++) {
      c=s.charAt(i);
      if(c=='A' || c=='C' || c=='G' || c=='T' ) {
        counter++;
        ans = Math.max(ans, counter);
      } else {
        ans = Math.max(ans, counter);
        counter = 0;
      }
    }
    System.out.println(ans);

    }
  }


Measured memory_bytes: 21844
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[1100];
int d[1100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)scanf("%d",c+i);
		for(int i=0;i<a;i++){
			pair<int,int>t=make_pair(99999,99999);
			for(int j=0;j<i;j++)t=min(t,make_pair(d[j],c[j]));
			int p=t.first;
			if(c[i]<t.second)p++;
		//	printf("%d ",p);
			p=(((p-1)/c[i]+1)*c[i]);
			if(p<=b){
				d[i]=p;
			}else{
				d[i]=b-b%c[i];
			}
	//		printf("%d ",d[i]);
		}
		pair<int,int> tmp=make_pair(99999,99999);
		int sz=0;
		int at=0;
		for(int i=0;i<a;i++){
			if(tmp>make_pair(d[i],c[i])){
				tmp=make_pair(d[i],c[i]);
				sz=1;
				at=i;
			}else if(tmp==make_pair(d[i],c[i])){
				sz++;
			}
		}
		if(sz>1)printf("%d\n",a);
		else printf("%d\n",at+1);
	}
}

Measured memory_bytes: 1036
s = int(input())
check = {};count = 1
check['{}'.format(s)] = True
while 1==1:
    count += 1
    if s % 2== 0:s = s//2 
    else:s = 3*s + 1
    try:
        if check['{}'.format(s)] == True:
            break
    except:pass
    check[str(s)] = True
print(count)

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

using namespace std;


int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n <= k)cout << x * n;
	else {
		cout << (x * k) + (n - k) * y;
	}
}

Measured memory_bytes: 256
N = int(input())
items = ["AC", "WA", "TLE", "RE"]
results = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(N):
    results[input()] += 1

for item in items:
    print("{} x {}".format(item, results[item]))

Measured memory_bytes: 9184
using System;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = InputIntArray();
        ulong count = 0;

        for(int i = 1; i < a.Length; i++)
        {
            if(a[i-1] > a[i])
            {
                int c =  a[i - 1] - a[i];
                a[i] += c;
                count +=(ulong) c;
            }

        }

        Console.WriteLine(count);


    }


    public static int[] InputIntArray()
    {
        string[] strs = Console.ReadLine().Split(' ');
        int[] num = new int[strs.Length];
        for (int i = 0; i < num.Length; i++)
        {
            num[i] = int.Parse(strs[i]);
        }

        return num;

    }
}




Measured memory_bytes: 45944
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int a[31] = {};
  REP(i,30) {
    int v;
    cin >> v;
    a[v] = 1;
  }
  REP(i,30) {
    if (a[i+1]==0)
      cout << i+1 << endl;
  }
}

Measured memory_bytes: 0
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll n, m;
    cin >> n >> m;
    ll a[n], count = 0, sum = 0;
    sidha (i, 0, n) {
        cin >> a[i];
        sum += a[i];
    }
    float x = (float)sum/(4*m);
    sidha (i, 0, n) 
        if (a[i] >= x) count++;
    if (count < m) cout << "No";
    else cout << "Yes";

    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1; x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y = y>>1; x = (x*x) % mod; 
    } 
    return res; 
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,j,h,w,a,s=0,mi,d[10][10],c[20],u[20]={};
  scanf("%d %d",&h,&w);
  for(i=0;i<10;i++){
    for(j=0;j<10;j++)scanf("%d",&d[i][j]);
    c[i]=1e9;
  }
  c[mi=1]=0;
  for(i=0;i<10;i++){
    u[mi]=1;
    for(j=0;j<10;j++){
      if(c[j]>c[mi]+d[j][mi])c[j]=c[mi]+d[j][mi];
    }
    mi=1;
    for(j=0;j<10;j++){//printf("%d ",c[j]);
      if(u[j])continue;
      if(mi==1||c[mi]>c[j])mi=j;
    }//printf("\n");
  }
  //for(i=0;i<10;i++)printf("%d\n",c[i]);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf("%d",&a);
      if(a>=0)s+=c[a];
    }
  }
  printf("%d\n",s);
  return 0;
}


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

int main(void){
  int N,i,j,sum=0,min=1000000;
  int x[105];
  scanf("%d\n",&N );
  for(i=0;i<N;i++){
    scanf("%d",&x[i] );
  }
  for(i=1;i<101;i++){
    for(j=0;j<N;j++){
      sum += pow(x[j]-i ,2);
    }
    if(sum < min){
      min = sum;
    }
    sum = 0;
  }
  printf("%d\n",min );
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
 
using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s1,s2,s3;
	int n,m;

	cin >> s1 >> s2 >> n >> m;
	map<string,int>ma;
	cin >> s3;
	ma[s1]=n;
	ma[s2]=m;
	
	ma[s3]--;

	cout << ma[s1] << " " << ma[s2] << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define F first
#define S second
#define mod 1000000007

signed main()
{
	
	int n; cin>>n;
	string s; cin>>s;
	s += "OOO";
	int ans = 0;
	for(int i=0; i<n; i++)
	{
		if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
			ans++;
	}
	cout<<ans<<"\n";
	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(x,y) for(lli i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli x,y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y;
	return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
m = int(math.sqrt(n)+1)

ans = int(999999999999999)
for i in range(1, m) :
    if n%i!=0 :
        continue
    
    j = int(n/i)
    ans = min(ans, max(len(str(j)), len(str(i))))

print(ans)

Measured memory_bytes: 3060
str = gets.chomp
q = gets.to_i
q.times do
  data = []
  data = gets.chomp.split(" ")
  a = data[1].to_i
  b = data[2].to_i
  case data[0]
  when "print" then puts str[a..b]
  when "reverse" then str[a..b] = str[a..b].reverse
  when "replace" then str[a..b] = data[3]
  end
end

Measured memory_bytes: 8812
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
	int a, b, c, d, e;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> e;
	cout << a - max((b + d - 1) / d,(c + e - 1) / e) << endl;
}





Measured memory_bytes: 3108
use proconio::input;

fn main() {
    input! {
        x: usize,
        y: usize,
        a: usize,
        b: usize,
        c: usize,
        mut p: [usize; a],
        mut q: [usize; b],
        mut r: [usize; c],
    }

    p.sort_by(|a, b| b.cmp(a));
    q.sort_by(|a, b| b.cmp(a));

    let mut cut_p: Vec<usize> = p.drain(..x).collect();
    let mut cut_q: Vec<usize> = q.drain(..y).collect();
    cut_p.append(&mut cut_q);
    cut_p.append(&mut r);

    cut_p.sort_by(|a, b| b.cmp(a));
    let sum: usize = cut_p.iter().take(x + y).sum();

    println!("{}", sum);
}


Measured memory_bytes: 11152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll linf = (1LL << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	stack<int> st;
	int pos = 0;
	int ans = 0;
	rep(i, n) {
		if (st.size() == 0) {
			st.push(a[i]);
			continue;
		}
		if (pos == 0) {
			if (st.top() < a[i]) pos = 1, st.push(a[i]);
			else if (st.top() > a[i]) pos = -1, st.push(a[i]);
			else st.push(a[i]);
		}
		else if (pos == 1) {
			if (st.top() <= a[i]) st.push(a[i]);
			else {
				while (st.size()) st.pop();
				ans++;
				st.push(a[i]);
				pos = 0;
			}
		}
		else {
			if (st.top() >= a[i]) st.push(a[i]);
			else {
				while (st.size()) st.pop();
				ans++;
				st.push(a[i]);
				pos = 0;
			}
		}
	}
	if (st.size()) ans++;
	cout << ans << endl;
	return 0;
}

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

int main() {
	int a, b, n;
	cin >> a >> b >> n;
	for (int i = 0; i < n; i++) {
		int s, e;
		cin >> s >> e;
		if (!(s >= b || e <= a)) {
			cout << 1 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 3132
import java.io.*;


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

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try{
            String line = reader.readLine();
            char[] word = new char[line.length()];
            int [] num = new int[line.length()];
            for(int i = 0; i < line.length(); i++){
                word[i] = line.charAt(i);
                num[i] = Integer.valueOf(word[i]);
                if(num[i] <= 90 && num[i] >= 65){
                    num[i] = num[i] + 32;
                }else if(num[i] <= 122 && num[i] >= 97){
                    num[i] = num[i] - 32;
                }
                word[i] = (char)num[i];
                System.out.print(word[i]);
            }
            System.out.println();    
        }catch(IOException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24836
square :: Int -> Int
square n = n * n

cube :: Int -> Int
cube n = n * n * n

addThree :: Int -> Int -> Int -> Int
addThree x y z = x + y + z

calc :: Int -> Int
calc n = addThree n (square n) (cube n)

toInt :: (String -> Int)
toInt x = read x :: Int

main = getLine >>= putStrLn . show . calc . toInt

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

int main() {
  int x,y,max_range,min_range;
  cin>>x>>y;
 /* if(x==1){
      if(y<5 && y%2==0)
      cout<<"Yes";
      else
      cout<<"No";
      return 0;
  }*/
  max_range=x*4;
  min_range=x*2;
  if(y<=max_range && y>=min_range){
      if(y%2==0)
      cout<<"Yes";
      else
      cout<<"No";
  }
  else
  cout<<"No";
}


Measured memory_bytes: 3600
n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
dp=[0]*(k+2)
dp[0]=1
for a in A:
    for i in range(1,k+1):
        dp[i]+=dp[i-1]
    for i in range(k,0,-1):
        dp[i]=(dp[i]-dp[max(0,i-a)-1])%mod
print(dp[k])

Measured memory_bytes: 42604
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextLong() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextDouble() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	for i, v := range a {
		if i > 0 {
			io.writer.WriteString(" ")
		}
		fmt.Fprintf(io.writer, "%v", v)
	}
	io.writer.WriteString("\n")
}

func (io *Io) Printfln(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format + "\n", a...)
}

func main() {
	io := NewIo()
	defer io.Flush()
	s := io.Next()
	kws := []string{"dream", "dreamer", "erase", "eraser"}
	dp := make([]bool, len(s) + 1)
	dp[0] = true
	for i := range s {
		for _, kw := range kws {
			if dp[i] && strings.HasPrefix(s[i:], kw) {
				dp[i + len(kw)] = true
			}
		}

	}
	//io.Println(dp)
	if dp[len(s)] {
		io.Println("YES")
	} else {
		io.Println("NO")
	}
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int main() {
    int h,w;cin>>h>>w;
    vector<bool> hv(h, false), wv(w, false);
    vector<vector<char>> a(h, vector<char>(w));
    rep(i,h) {
        rep(j,w) {
            char x;cin>>x;
            if(x=='#') {
                hv.at(i)=true;
                wv.at(j)=true;
            }
            a.at(i).at(j)=x;
        }
    }
    rep(i,h) {
        bool f = false;
        rep(j,w) {
            if(hv.at(i)&&wv.at(j)) {
                cout<<a.at(i).at(j);
                f = true;
            }
        }
        if(f) cout<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(void){
  int n,m,i,a,b;
  vector<P> y;
  cin >> n >> m;
  for (i=0;i<n;i++){
    cin >> a >> b;
    y.push_back(P(b,a));
  }
  sort(y.begin(),y.end(),greater<P>());
  
  int ans=0;
  vector<int> sr;
  vector<int>::iterator vi;
  for (i=1;i<=m;i++) sr.push_back(i);
  for (i=0;i<n;i++){
    vi=lower_bound(sr.begin(),sr.end(),y[i].second);
    if (vi!=sr.end()){
      ans+=y[i].first;
      sr.erase(vi);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)cin>>A[i];
    sort(all(A));
    vector<ll> cum(N+1,0);
    rep(i,N)cum[i+1] += cum[i] + A[i];
    auto check = [&](int idx){
        ll sum = cum[idx+1];
        for(int i = idx+1; i < N; i++){
            if(A[i] <= 2 * sum)sum += A[i];
            else{
                return false;
            }
        }
        return true;
    };
    int ng = -1;
    int ok = N;
    while(ok - ng > 1){
        int mid = (ok + ng) >> 1;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    int ans = N - ok;
    cout << ans << endl;
}

Measured memory_bytes: 1792
var
 a:array[0..4] of longint;
 t,i,j:longint;
begin
 readln(a[1],a[2],a[3]);
 for i:=1 to 2 do
  for j:=i+1 to 3 do
   if a[i]>a[j] then
    begin
     t:=a[i];
     a[i]:=a[j];
     a[j]:=t;
    end;
 write(a[1]+a[2]);
end.

Measured memory_bytes: 128
#include<stdio.h>

int main(){
	int a;
	int b;
	int c;
	int d;
	int i;
	scanf("%d", &d);
	for(i = 0; i < d; i++){
		scanf("%d", &a);
		scanf("%d", &b);
		scanf("%d", &c);
		if(a * a == b * b + c * c){
			printf("YES\n");
		}else if(b * b == a * a + c * c){
			printf("YES\n");
		}else if(c * c == a * a + b * b){
			printf("YES\n");
		}else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 580
n = int(input())
ans_list = [[0] * 10 for i in range(10)]
for i in range(1, n+1):
  sn = str(i)
  a = int(sn[0])
  b = int(sn[-1])
  ans_list[a][b] += 1
ans = 0
for i in range(1, 10):
  for j in range(1, 10):
    ans += ans_list[i][j] * ans_list[j][i]
print(ans)

Measured memory_bytes: 3064
//なにもわからない
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int tmp[200001];
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort(N, F);
	reverse(F, F + N);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			if((ll)A[i] * F[i] > M) kazu += A[i] - M / F[i];
			if (kazu > K) break;
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);


	Would you please return 0;
}

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

int main(){
  long n;
  cin >> n;
  vector<long> capasity(5);
  cin >> capasity[0];
  long minTemp = capasity[0];
  for(int i=1; i<capasity.size(); i++){
    cin >> capasity[i];
    minTemp = min(minTemp, capasity[i]);
  }
  cout << (n-1)/minTemp + 5 << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


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

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

int main() {
  int n, m = 8;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    int c = 0;
    for (int j = 1; j <= i; j++) {
      c += i % j == 0;
    }
    if (c == m) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int K = in.Int();
            long sum = 0;
            for (int i = 1; i <= K; i++) {
                for (int j = 1; j <= K; j++) {
                    for (int k = 1; k <= K; k++) {
                        sum += gcd(i, gcd(j, k));
                    }
                }
            }
            out.println(sum);
        }

        long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 33024
while True:
    try:
        x1, y1, x2, y2, xq, yq = map(float, input().split(","))
        if (y2-y1) == 0:
            xr = xq
            yr = 2*y1 - yq
        elif (x2-x1) == 0:
            xr = 2*x1 - xq
            yr = yq
        else:
            a12 = (y2-y1)/(x2-x1)
            aqr = -1/a12
            b12 = y1 - a12*x1
            bqr = yq - aqr*xq
            xm  = -(b12-bqr)/(a12-aqr)
            ym  = aqr*xm + bqr
            xr = 2*xm - xq
            yr = 2*ym - yq
        print(xr, yr)
    except:
        break



Measured memory_bytes: 5580