akhauriyash/Code-Regression huggingface dataset:
def grid(maze,h,w):
    mod = 7+10**9
    visited = [[0]*w for _ in range(h)]
    for i in range(h):
        for j in range(w):
            if maze[i][j] == "#":
                continue

            if i==0 and j==0:
                visited[i][j] = 1
                
            
            elif i == 0:
                visited[i][j] = visited[i][j-1]
            elif j == 0:
                visited[i][j] = visited[i-1][j]
            else:
                visited[i][j] = (visited[i-1][j]%mod + visited[i][j-1]%mod)%mod
    
    return visited[h-1][w-1]


h,w = map(int,input().split())

maze = []

for _ in range(h):
    maze.append(list(input()))

print(grid(maze,h,w))


Measured memory_bytes: 56276
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long A[] = new long[N + 1];
		long B[] = new long[N + 1];
		for(int i = 0; i < N + 1; i++) {
			A[i] = sc.nextLong();
		}
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextLong();
		}
		
		long ans = 0;
		for(int i = 0; i < N; i++) {
			if(A[i] - B[i] < 0) {
				ans += A[i];
				B[i] -= A[i];
				if(A[i + 1] < B[i]) {
					ans += A[i + 1];
					A[i + 1] = 0;
				} else {
					ans += B[i];
					A[i + 1] -= B[i];
				}
			} else {
				ans += B[i];
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 89540
#include <iostream>
#include <iomanip>
using namespace std;
#define pi 3.14159265358979323846
 
int main(){
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  double ans = 2*pi*n;
  cout<<setprecision(15);
  cout<<fixed;
  cout<<ans<<endl;
  
 
}

Measured memory_bytes: 3260
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] P = new int[N];
        int[] Q = new int[N];
        ArrayList<Integer> Pnumlist = new ArrayList<Integer>();
        ArrayList<Integer> Qnumlist = new ArrayList<Integer>();
        int[] fact = new int[N];

        fact[0] = 1;
        for(int i =1; i <N;i++){
            fact[i] = fact [i-1] * i;
        }
        for(int i=0;i<N;i++){
            Pnumlist.add(i+1);
            Qnumlist.add(i+1);
        }

        for(int i =0;i<N;i++){
            P[i] = sc.nextInt();
        }

        for(int i=0;i<N;i++){
            Q[i] = sc.nextInt();
        }

        int Pans =1;
        int Qans =1;
        for(int i=0;i<N;i++){
            Pans += fact[N-i-1] * (Pnumlist.indexOf(P[i]));
            Pnumlist.remove(Pnumlist.indexOf(P[i]));
            Qans += fact[N-i-1] * (Qnumlist.indexOf(Q[i]));
            Qnumlist.remove(Qnumlist.indexOf(Q[i]));

        }



        System.out.println(Math.abs(Pans-Qans));


    }

}


Measured memory_bytes: 23252
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
    std::vector<int> vec(3);
    for (int i = 0; i < 3; i++) {
        std::cin >> vec[i];
    }
    std::sort(vec.begin(), vec.end());

    std::cout << vec[0] << " " << vec[1] << " " << vec[2] << std::endl;
    return 0;
}



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

int main(){
  int N,i,j;
  scanf("%d",&N);
  int num[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  int mass[15];
  for(i=0;i<15;i++){mass[i]=0;}
  
  for(i=0;i<15;i++){
    j=1;
    while(N>=pow(num[i],j)){
      mass[i]=mass[i]+(int)(N/pow(num[i],j));
      j++;
    }
  }
  //for(i=0;i<5;i++){printf("%d " ,num2[i]);}
  
  int num2[5];
  for(i=0;i<5;i++){num2[i]=0;}
  for(i=0;i<15;i++){
    if(74<=mass[i]){num2[0]++;}
    if(24<=mass[i]){num2[1]++;}
    if(14<=mass[i]){num2[2]++;}
    if(4<=mass[i]){num2[3]++;}
    if(2<=mass[i]){num2[4]++;}
  }
  //for(i=0;i<5;i++){printf("%d " ,num2[i]);}
  int ans=0;
  ans=num2[0];
  ans=ans+num2[1]*(num2[4]-1);
  ans=ans+num2[2]*(num2[3]-1);
  ans=ans+num2[3]*(num2[3]-1)*(num2[4]-2)/2;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n,k,x[100],b[100],sum;
    sum=0;
    cin >>n>>k;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=0;i<n;i++){
        if(x[i]>k){
            b[i]=x[i]-k;
        }
        else {
            b[i]=k-x[i];
        }
    }
    for(int i=0;i<n;i++){
        if(x[i]*2<b[i]*2){
            sum+=2*x[i];
        }
        else{
            sum+=b[i]*2;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
 
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define gap cout<<endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
int total;
const int N=100005;
int visited[N];
int coount[N];
vector<int> adj[N];
std::vector<ii> edges; 
map<ii,int> colors;

void dfs(int node,int color){
    visited[node]=1;
    for(auto j:adj[node]){
        if(visited[j]) continue;
        colors[{node,j}]=(color)%total;
        dfs(j,(color+1)%total);
        color++;
        color=(color)%total;
    }
}
 
int main(){
    int n;
    cin>>n;
    int maax=0;
    int a,b;
    fo(i,n+1){
        visited[i]=0;
        coount[i]=0;

    }
    fo(i,n-1){
        cin>>a>>b;
        coount[a]++;
        coount[b]++;
        maax=max(coount[a],maax);
        maax=max(coount[b],maax);
        edges.pb({a,b});
        adj[a].pb(b);
        adj[b].pb(a);

    }
    total=maax;
    dfs(1,0);
    cout<<total<<endl;
    for(auto j:edges){
        if(colors.count(j)) cout<<colors[j]+1<<endl;
        else cout<<colors[{j.second,j.first}]+1<<endl;
    }
   
 
    
}

Measured memory_bytes: 15480
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

n_abs = N.abs
@plus = []
x = 0
i = 0
while x < n_abs
  x += 4 ** i
  @plus << x
  i += 1
end

@minus = []
x = 0
i = 0
while x < n_abs
  x += 2 * 4 ** i
  @minus << x
  i += 1
end

def check(n)
  return [-1, n] if n == 1 || n == 0

  if n > 0
    index = @plus.bsearch_index { |x| x >= n }
    [index, n - 4 ** index, 'plus']
  else
    index = @minus.bsearch_index { |x| x >= n.abs }
    [index, n + 2 * 4 ** index, 'minus']
  end
end

ans = []
test = N
loop do
  stock = check(test)
  ans << stock
  test = stock[1]
  break if stock[0] < 0
end

result = []
ans.each do |index, v, type|
  if type == 'minus'
    result[2 * (index+1)-1] = '1'
  elsif type == 'plus'
    result[2 * index] = '1'
  else
    result[0] = v
  end
end

puts result.map { |x| x == nil ? '0' : x }.reverse.join


Measured memory_bytes: 14528
#include <stdio.h>

int main(void) {
	int c1,c2,c3;
	int kakuritu;
	int ato;
	while(1) {
		if(scanf("%d %d %d",&c1,&c2,&c3)==-1)break;
		kakuritu=ato=20-c1-c2;
		if(c1<=ato)kakuritu--;
		if(c2<=ato)kakuritu--;
		if(c3<=ato)kakuritu--;
		if(kakuritu*10/7>=5)printf("YES\n"); else printf("NO\n");
	}
}

Measured memory_bytes: 0
"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), M = cin.getInt();
    let A = cin.getIntArray(N);
    let m = {};
    let SUM = new Array(N + 1);
    SUM[0] = 0;
    for (let i = 0; i < N; i++) {
        SUM[i + 1] = (SUM[i] + A[i]) % M;
    }
    let ans = 0;
    for (let i = 0; i < SUM.length; i++) {
        let sum = m[SUM[i]] || 0;
        ans += sum;
        m[SUM[i]] = sum + 1;
    }
    console.log(ans);
}
class Inputer {
    constructor (input) {
        this.cnt = 0;
        this.items = input.split(/\n|\s/);
    }
    getInt() {
        return this.items[this.cnt++] - 0;
    }
    getIntArray(N) {
        let array = new Array(N);
        for (let n = 0; n < N; n++) array[n] = this.getInt();
        return array;
    }
    getStr() {
        return this.items[this.cnt++];
    }
    getStrArray(N) {
        let array = new Array(N);
        for (let n = 0; n < N; n++) array[n] = this.getStr();
        return array;
    }
}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33228
n,m = map(int,input().split())
e = [0]*(n)
for i in range(n):
    e[i] = []
c = []
for i in range(m):
    a,b = map(int,input().split())
    c.append([a-1,b-1])
    e[a-1].append(b-1)
    e[b-1].append(a-1)

def dfs(g,s,e):
    vis = []
    q = []
    vis.append(s)
    for i in range(len(g[s])):
        q.append(g[s][i])
    while len(q):
        ne = q.pop()
        vis.append(ne)
        if ne == e:
            return 1
        for i in range(len(g[ne])):
            if g[ne][i] in vis:
                continue
            if g[ne][i] == e:
                return 1
            q.append(g[ne][i])
            vis
    return 0
ans = 0
for i in range(len(c)):
    vis =[]
    f = 0
    fr = c[i][0]
    end = c[i][1]
    e[fr].remove(end)
    e[end].remove(fr)
    if dfs(e,fr,end) is 0:
        ans += 1
    e[fr].append(end)
    e[end].append(fr)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;

#define MAX_S 10
int a[MAX_S];

int ctoi(char c) {
  switch (c) {
  case '0': return 0;
  case '1': return 1;
  case '2': return 2;
  case '3': return 3;
  case '4': return 4;
  case '5': return 5;
  case '6': return 6;
  case '7': return 7;
  case '8': return 8;
  case '9': return 9;
  default: return 0;
  }
}


int main() {

  // ---------------------
  // Input
  
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++)  {
    a[i] = ctoi(S[i]);
  }

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

  ll ans = 0;
  ll n = S.size() - 1;
  
  for (ll bit = 0; bit < (1<<n); bit++) {
    
    ll keta = 1;

    for (ll i = 0; i < n; i++)  {

      ans += a[n - i] * keta;
      
      if (bit & (1<<i)) {
	keta = 1;
      }
      else {
	keta = keta*10;
      }
    }

    ans += a[0] * keta;
    
  }
  
  
  cout << ans << endl;

  return 0;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

int main(){
    string x;
    cin >> x;
    int start, end;
    for (int i=0;i<x.size();i++){
        if (x[i] == 'A'){
            start = i;
            break;
        }
    }
    for (int i=0;i<x.size();i++){
        if (x[i] == 'Z'){
            end = i;
        }
    }
    cout << end - start + 1 << endl;
    return 0;
}

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    ll n,k;
    cin>>n>>k;
    vector<ll> v,u;
    ll pos = 0, mi = 0,z=0;
    for(int i=0;i<n;i++){
        ll a; cin>>a;
        if(a > 0) pos++,v.push_back(a);
        else if(a==0) z++;
        else mi++,u.push_back(-a);
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end());
    if(pos*mi >= k){
        ll low = -1,up=1e18+66,mid;
        while(up-low>1){
            mid = (up+low)/2;
            ll cnt = 0;
            for(ll i:u){
                cnt += v.end() - lower_bound(v.begin(),v.end(),(mid+i-1)/i);
            }
            if(cnt < k) up = mid;
            else low = mid;
            cerr << mid << " " << cnt << endl;
        }
        cerr << low << " " << up  << endl;
        cout << -low << endl;
        // ans = min(hoge <= up == 1)
        // ll ans = 1e18;
        // for(ll i:u){
        //     auto itr = upper_bound(v.begin(),v.end(),(up+i-1)/i);
        //     if(itr==v.begin())continue;
        //     itr--;
        //     ans = min(ans,-i*(*itr));
        // }
        // cout << ans << endl;
        return 0;
    }
    else if(pos*mi + z*(n-z) + z*(z-1)/2 >=k){
        cout << 0 << endl;
        return 0;
    }
    else {
        ll ba = pos*mi + z*(n-z) + z*(z-1)/2;
        ll low = -1,up=1e18+5,mid;
        while(up-low>1){
            mid = (up+low)/2;
            ll cnt = 0;
            for(ll i:v){
                cnt += upper_bound(v.begin(),v.end(),mid/i) - v.begin();
                if(i*i<=mid) cnt--;
            }
            for(ll i:u){
                cnt += upper_bound(u.begin(),u.end(),mid/i) - u.begin();
                if(i*i<=mid) cnt--;
            }
            cnt /= 2;
            cnt += ba;
            if(cnt < k) low = mid;
            else up = mid;
            //cerr << mid << " " << cnt << endl;

        }
        cout << up << endl;
    }
}

Measured memory_bytes: 2420
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int a, b, k; readV(a, b, k);
  if (a+k-1 < b-k+1) {
    foreach (i; a..a+k) writeln(i);
    foreach (i; b-k+1..b+1) writeln(i);
  } else {
    foreach (i; a..b+1) writeln(i);
  }
}


Measured memory_bytes: 380
import Data.List
import Data.Int

main = do
  [n,k]<-map read.words<$>getLine
  putStr $ solve n k

solve :: Int64 -> Int64 -> String
solve n k =  unlines $ map (show.f) [1..k] where
   f i = division *% bunpai where
    division = prodm 1 (k-1) *% inv(prodm 1 (i-1) *% prodm 1 (k-i))
    bunpai = combm (n-k+1) i

mo = 10^9 + 7
a *% b = mod (a*b) mo
a ^% b = foldl (*%) 1 (replicate b a)
prodm n m = foldl (*%) 1 [n..m]
combm n r = prodm (n-r+1) n *% inv (prodm 1 r)
inv x = u where (u,_,_) = euc x mo
euc = go 1 0 0 1 where
  go u v u' v' x 0 = (u,v,x)
  go u v u' v' x y = go u' v' (u - q * u') (v - q * v') y r
    where (q,r) = quotRem x y

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

void solve(){
  int n,sum=0;cin>>n;
  vector<int>a(n+1),ans(n+1,0);
  for(int i=1;i<=n;i++)cin>>a[i];
  for(int i=n;1<=i;i--){
    int b=0;
    for(int j=i;j<=n;j+=i){
      b+=ans[j];
    }
    if(b%2==a[i])ans[i]=0;
    else {ans[i]=1;sum++;}
  }
  cout<<sum<<endl;
  for(int i=1;i<=n;i++)if(ans[i])cout<<i<<" ";
  if(sum!=0)cout<<endl;
}

int main(){
  solve();
}


Measured memory_bytes: 2432
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	cin>>n>>m;
	vector<int> g[606];
	for(int i=0; i<m; i++){
		int s, t; cin>>s>>t;
		s--; t--;
		g[s].push_back(t);
	}
	double p[606][606]={};
	for(int i=0; i<n; i++){
		p[i][i]=1;
		for(int j=0; j<n; j++){
			int d=g[j].size();
			for(auto y:g[j]){
				p[i][y]+=p[i][j]/d;
			}
		}
	}
	double e[606]={};
	for(int i=0; i<n; i++){
		for(int j=0; j<n-1; j++) e[i]+=p[i][j];
	}
	double ans=e[0];
	for(int i=0; i<n; i++){
		int d=g[i].size();
		if(d<=1) continue;
		double ans1=e[0];
		for(auto y:g[i]){
			ans1+=p[0][i]/d/(d-1)*e[y];
		}
		for(auto y:g[i]){
			ans=min(ans, ans1-p[0][i]/(d-1)*e[y]);
		}
	}
	printf("%.7lf\n", ans);
	return 0;
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
int N;
  cin>> N;
  if(105>N)
  {
  cout << 0;
  }else if(195<=N)
  {
  cout << 5;
  }else if(189<=N)
  {
    cout << 4;
  }else if(165<=N)
  {
  cout << 3;
  }else if (135 <=N)
  {
  cout << 2;
  }else
  {
  cout << 1;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>

using namespace std;

void solve()
{
	int n, m;
	while(cin >> n >> m, n || m)
	{
		long double data[101][101];
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				scanf("%Lf", &data[i][j]);
			}
		}
		long double dp[101][101];
		for(int i = 0; i < m; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				dp[i][j] = 0;
			}
		}
		for(int i = 0; i < n; ++i)
		{
			dp[0][i] = 1;
		}
		for(int i = 1; i < m; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				for(int k = 0; k < n; ++k)
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][k] * data[k][j]);
				}
			}
		}
		long double maximum = 0;
		for(int i = 0; i < n; ++i)
		{
			maximum = max(maximum, dp[m - 1][i]);
		}
		printf("%.2Lf\n", maximum);
	}
}

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

Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(), x.end()
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

int n, k;
vector<int> a;
map<int, int> mp;
ll solve()
{
    ll ans = 0;

    for (auto &it : mp)
    {
        a.push_back(it.second);
    }
    sort(all(a));
    int cur = mp.size();
    rep(i, a.size())
    {
        if (cur > k)
        {
            cur--;
            ans += a[i];
        }
        if (cur <= k)
            break;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    rep(i, n)
    {
        int ai;
        cin >> ai;
        mp[ai]++;
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 10744
#include <iostream>
#include <string>
#define llt long long int

using namespace std;
int main()
{
    string s;
    llt count = 700;

    cin >> s;
    if (s[0] == 'o')
        count += 100;
    if (s[1] == 'o')
        count += 100;
    if (s[2] == 'o')
        count += 100;
    cout << count << endl;

    return 0;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    int sum=0;
    vector<int>t(n);
    rep(i,n){
        cin>>t[i];
        sum+=t[i];
    }
    int m;
    cin>>m;
    vector<int>p(m),x(m);
    rep(i,m){
        cin>>p[i]>>x[i];
    }
    rep(i,m){
        cout<<sum-(t[p[i]-1]-x[i])<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
#define C(_Dis) cout<<_Dis<<endl;

using namespace std;

typedef long long int lli;

int main() {
	int n,Count=0;
	while (cin >> n) {
		L(i, 10)L(j, 10)L(k, 10)L(l, 10)if (i + j + k + l == n) Count++;
		C(Count);
		Count = 0;
	}
	return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    int t;
    LL a, b, c;
    scanf("%lld%lld%lld", &a, &b, &c);
    if (a == b && a != c || a == c && a != b || a != b && b == c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
    /*scanf("%d", &t);
    for (int i = 1; i <= t; i++)
        solve(i);
        */
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
inline int in(){int x;scanf("%lld",&x);return x;}

int32_t main()
{
	int a=in();int b=in();
	if(a<=5)cout<<0;
	else if(a<=12 and a>=6)cout<<(b/2);
	else cout<<b;
	
}

Measured memory_bytes: 3660
t = []
for i in range(5):
  t.append(int(input()))
total = 0
#add the x%10==0s first
#let the last one be x%10 is minimum but not 0
#How am I suppose to compare infinite numbers in pyhton like in c?

last = 256

for x in t:
  if x%10 ==0:
    total+=x
    t.pop(t.index(x))
  elif last>200 or x%10<last%10:
    last = x
if last < 200:
  t.pop(t.index(last))
  t.append(last)
for i in range(len(t)):
  temp = total
  if i==0:
    total+=t[i]
  else:
    if t[i-1]%10 == 0:
      total += t[i]
    else:
      total += t[i] + (10 - t[i-1]%10)
print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k, s;
    cin >> n >> k >> s;
    long long INF = 10000000000;
    vector <long long> ans(n, INF);
    for (int i; i < k; i ++){
        ans[i] = s;
    }
    for (int i; i < n; i ++){
        if (ans[i] == INF){
            if (s == 1000000000){
                ans[i] = 1;
            }
            else{
                ans[i] = 1000000000;
            }
        }
    }
    for (int i; i < n; i ++) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 3996
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;

void main() {
    auto tmp = readln.split.map!(to!int).array;
    auto X = tmp[0];
    auto Y = tmp[1];
    auto Z = tmp[2];
    //X >= n * Y + (n+1)*Z
    //X >= n * (Y+Z) + Z
    writeln((X-Z) / (Y+Z));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (long long)1e17
using namespace std;

// 1-indexed
template <class T, class E>
struct SegmentTreeLaze {
  // a,b:T c,d:E e:E(unit)
  // g(f(a,b),c) = f(g(a,c),g(b,c))
  // g(g(a,c),d) = g(a,h(c,d))
  // g(a,e) = a
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

struct data {
  long long l, r, c;
};
bool operator<(const data &l, const data &r) {
  if(l.l != r.l) return l.l < r.l;
  if(l.r != r.r) return l.r < r.r;
  return l.c < r.c;
};

long long n, m;
vector<data> v;

long long sovle();

int main() {
  cin >> n >> m;
  v.resize(m);
  for(int i = 0; i < m; ++i)
    cin >> v[i].l >> v[i].r >> v[i].c;
  sort(v.begin(), v.end());
  cout << sovle() << endl;
  return 0;
}

long long sovle() {
  auto f = [](long long l, long long r) {
    return min(l, r);
  };
  auto g = [](long long l, long long r) {
    return min(l, r);
  };
  auto h = [](long long l, long long r) {
    return min(l, r);
  };
  SegmentTreeLaze<long long, long long> seg(n + 2, f, g, h,
                                            inf, inf);
  seg.update(1, 2, 0);
  for(int i = 0; i < m; ++i) {
    long long now = seg.query(v[i].l, v[i].l + 1);
    if(now == inf) continue;
    now += v[i].c;
    seg.update(v[i].l, v[i].r + 1, now);
  }
  if(seg.query(n, n + 1) == inf) return -1;
  return seg.query(n, n + 1);
}

Measured memory_bytes: 6656
n = int(input())
l = sorted(map(int, input().split()))
 
ans = 0
for i in range(n):
    for j in range(i+1, n):
        big = l[i]+l[j]
    
        ch_max = n
        ch_min = j+1
        
        while ch_min < ch_max:
            ch_i = (ch_min + ch_max) // 2
            if l[ch_i] < big:
                ch_min = ch_i + 1
            else:
                ch_max = ch_i
                
        big_i = ch_max
        
        ans += big_i - (j + 1)
                
print(ans)

Measured memory_bytes: 42220
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
ll N,a,b,c,d;
map<ll,ll>dp;
ll solve(ll n)
{
	if(n == 0)return 0;
	if(n == 1)return d;
	if(dp.find(n) != dp.end())return dp[n];
	ll res = 1e18;
	if(res/n > d)res = n*d;
	ll k1 = (n/2)*2;
	ll k2 = ((n+1)/2)*2;
	ll l1 = (n/3)*3;
	ll l2 = ((n+2)/3)*3;	
	ll r1 = (n/5)*5;
	ll r2 = ((n+4)/5)*5;	
	
	res = min(res,abs(n-k1)*d + a + solve(k1/2));
	res = min(res,abs(n-k2)*d + a + solve(k2/2));
	
	res = min(res,abs(n-l1)*d + b + solve(l1/3));
	res = min(res,abs(n-l2)*d + b + solve(l2/3));
	
	res = min(res,abs(n-r1)*d + c + solve(r1/5));
	res = min(res,abs(n-r2)*d + c + solve(r2/5));
	dp[n] = res;
	return res;
}
int main()
{
  int t;
  cin>>t;
  while(t--)
  {
    cin>>N>>a>>b>>c>>d;
    dp.clear();
    cout<<solve(N)<<endl;
  }
   
}


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

string str;

int main(){
	cin >> str;
	int val = true;
	for(int i = 0; i < (int)str.length(); i++)
		if((str[i] == 'L' && (i + 1) % 2 == 1) || (str[i] == 'R' && (i + 1) % 2 == 0)) val = false;
	cout << (val ? "Yes\n" : "No\n");
	return 0;
}



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

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

    long long a[n+1], b[n+1];

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

    long long button = 0;

    for(int i = n; i >= 1; i--){
        if((a[i]+button) % b[i] == 0){
            continue;
        }
        long long amari = (a[i]+button) % b[i];
        button += (b[i]-amari);
    }

    printf("%lld\n", button);
}

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



typedef long long ll;
int arr[200005];
ll psum[200005];

int main()
{
    int n;
    cin>>n;
    ll tot=0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        tot+=arr[i];
    }


    for(int i=1;i<=n;i++)
        psum[i]=psum[i-1]+arr[i];

    ll ret=1e15;
    for(int i=1;i<n;i++)
        ret=min(ret,abs(tot-psum[i]-psum[i]));
    cout<<ret;

}


Measured memory_bytes: 2560
a,b,c,d=input()
if a==b:
    if c==d and a!=c:
        print('Yes')
    else:
        print('No')
elif a==c:
    if b==d and a!=b:
        print('Yes')
    else:
        print('No')
elif a==d:
    if b==c and a!=b:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 2940
#include<iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include <functional>
using namespace std;
struct ci {
	int order;
	int p;
	int y;
	bool operator<(const ci &another) const
	{
		return y < another.y;//年齢を比較
	};
	int id;
};
bool cmp(const ci &a, const ci &b)
{
	return a.order < b.order;
}
int main(void) {
	int N, M;
	struct ci c[100000];
	int c_num[100000];
	cin >> N >> M;
	for (int i = 0;i < M;i++) {
		cin >> c[i].p >> c[i].y;
		c[i].order=i;
	}
	for (int i = 0;i < N;i++)
		c_num[i] = 1;
	sort(c, c + M);
	for (int i = 0;i < M;i++) {
		c[i].id = c_num[c[i].p - 1];
		c_num[c[i].p - 1]++;
	}
	sort(c, c + M, cmp);
	for (int i = 0;i < M;i++) {
		printf("%06d%06d\n", c[i].p, c[i].id);
	}

	return 0;

}


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


void solve(long long A, long double B){
  cout << (long long)floor(A * B) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long double B;
  scanf("%Lf",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a[10000000],n,c=1;
    for(int i=0;i<100;i++){
        a[i]=0;
    }
    cin >> n;
    a[n]=1;
    while(true){
        c++;
        if(n%2==1){
            n=3*n+1;
        }else{
            n=n/2;
        }
        if(a[n]!=0){
            cout << c << endl;
            break;
        }else{
            a[n]=c;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int dp[20000][256];
signed main(){
  for(int n,m;cin>>n>>m,n;){
    int c[20000],x[20];
    for(int i=0;i<n;i++) fill(dp[i],dp[i]+256,(int)1e9);
    for(int i=0;i<m;i++) cin>>x[i];
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<m;i++){
      int num=128+x[i];
      if(num<0) num=0;
      if(num>255) num=255;
      dp[0][num]=(int)pow(num-c[0],2);
    }
    for(int i=1;i<n;i++){
      for(int j=0;j<256;j++){
	if(dp[i-1][j]!=(int)1e9){
	  for(int k=0;k<m;k++){
	    int num=j+x[k];
	    if(num<0) num=0;
	    if(num>255) num=255;
	    dp[i][num]=min(dp[i][num],dp[i-1][j]+(int)pow(c[i]-num,2));
	  }
	}
      }
    }
    /*
      for(int i=0;i<n;i++){
      for(int j=0;j<256;j++) cout<<(dp[i][j]!=1e9?dp[i][j]:-1)<<" ";
      cout<<endl;
      }*/
    int sm=1e9;
    for(int i=0;i<256;i++) sm=min(sm,dp[n-1][i]);
    cout<<sm<<endl;
  }
  return 0;
}



Measured memory_bytes: 23152
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	int a1,a2,a3,t1,t2,t3,t4,t5,t6;
	scanf("%d %d %d",&a1,&a2,&a3);
	int b,c;
	b=abs(a3-a1);
	c=abs(a2-a1);
	int d=abs(a2-a3);
	int e=abs(a3-a2);
	int x=abs(a1-a2);
	int y=abs(a1-a3);
	 //when first one used first:
	 t1=b+d;
	 t2=c+e;
	 if(t1>t2)
	 {
	 	t1=t2;
	 }
	 else
	 {
	 	 t1=t1;
	 }
	 //when second one used first:
	 t3=x+b;
	 t4=e+y;
	 if(t3>t4)
	 {
	 	t3=t4;
	 }
	 else
	 {
	 	t3=t3;
	 }
	 //when the 3rd one will used first:
	 t5=d+x;
	 t6=y+c;
	 if(t5>t6)
	 {
	 	t5=t6;
	 }
	 else
	 {
	 	t5=t5;
	 }
	 if(t1<=t3 && t1<=t5)
	 {
	 	printf("%d",t1);
	 }
	 else if(t3<=t1 && t3<=t5)
	 {
	 	printf("%d",t3);
	 }
	 else if(t5<=t3 && t5<=t1)
	 {
	 	printf("%d",t5);
	 }
	return 0;
}


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

int main() {
	int S,i,j,sum;
	cin >> S;

	if (S < 5)
		cout << 0 << endl;
	else if (500 < S && S < 5) {
		i = S / 5;
		sum = i * 5;
		cout << sum << endl;
	}
	else {
		i = S / 500;
		S -= 500*i;
		sum += i * 1000;
		if (S > 5) {
			j = S / 5;
			sum += j * 5;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;


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

	//cout << "water:" << water << endl;

	long double mid_angle = atan2(a , b);

	long double ok = M_PI / 2.0;
	long double ng = 0;

	while(fabs(ok - ng) > 0.000000000001) {
		long double mid = (ok + ng) / 2;
		long double cur;
		//cout << "mid:" << mid << " mid_angle:" << mid_angle << endl;
		if (a * tan(mid) <= b) {
			cur = a * a * b - a * a *  a * tan(mid) / 2.0;
			//cout << "mid_angle < mid" << endl;
		} else {
			cur = a * b * b / tan(mid) / 2.0;
			//cout << "mid_angle >= mid" << endl;

		}
		//cout << "ok:" << ok << " ng:" << ng << " cur:" <<  cur << endl;
		if (cur < x) {
			ok = mid;
		} else { 
			ng = mid;
		}
	}

	cout << fixed << setprecision(10) << ok  / M_PI * 180.0 << endl;





	return 0;
}



Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main()
{
  int H, W;
  cin >> H >> W;

  char map[H][W], map_tmp[H][W];
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){   
      cin >> map[i][j];
      map_tmp[i][j] = map[i][j];
    }
  }
  
  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W-1; ++j){
      if(map[i][j] == '#' && map[i][j+1] == '#'){
        map_tmp[i][j] = '.';
        map_tmp[i][j+1] = '.';
      }
    }
  }
  
  for(int i = 0; i < W; ++i){
    for(int j = 0; j < H-1; ++j){
      if(map[j][i] == '#' && map[j+1][i] == '#'){
        map_tmp[j][i] = '.';
        map_tmp[j+1][i] = '.';
      }
    }
  }

  for(int i = 0; i < H; ++i){
    for(int j = 0; j < W; ++j){
      if(map_tmp[i][j] == '#'){
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,LL> P;
const LL mod=1000000007;
const LL INF=1000000000000000;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    priority_queue<LL,vector<LL>,greater<LL>> fr;
    priority_queue<LL> ba;
    vector<LL> v;
    vector<LL> ans1,ans2;
    int N;
    cin >> N;
    LL sfr=0,sba=0;
    for(int i=0;i<3*N;i++){
        LL t;
        cin >> t;
        v.push_back(t);
        if(i<N){
            fr.push(t);
            sfr+=t;
        }
        else if(2*N<=i){
            ba.push(t);
            sba+=t;
        }
    }
    ans1.push_back(sfr);
    ans2.push_back(sba);
    for(int i=N;i<2*N;i++){
        fr.push(v[i]);
        sfr+=v[i];
        sfr-=fr.top();
        fr.pop();
        ans1.push_back(sfr);
    }
    for(int i=2*N-1;i>=N;i--){
        ba.push(v[i]);
        sba+=v[i];
        sba-=ba.top();
        ba.pop();
        ans2.push_back(sba);
    }
    LL ans=-INF;
    for(int i=0;i<=N;i++){
        ans=max(ans,ans1[i]-ans2[N-i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (k < max({a, b, c, d, e}) - min({a, b, c, d, e})) {
        cout << ":(" << endl;
    }
    else {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s, t;
	cin>>s>>t;
	sort(all(s)); sort(all(t)); reverse(all(t));
	cout<<(s<t?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
template <typename CT, typename T> inline void reset_container(CT &c, int sz, T v){c.resize(sz); for(auto &x: c) x=v;}
#define taskname "B"
string s;
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    cin>>s;
    ll ans=0;
    int cnt=0;
    char old='A';
    for(char c: s){
        if(c=='A'){
            if(old=='A') cnt++;
            else{
                old='A';
                cnt=1;
            }
        }
        else if(c=='B'){
            if(old!='A') cnt=0;
            old='B';
        }
        else if(c=='C'){
            if(old!='B') cnt=0;
            else{
                ans+=cnt;
                old='A';
            }
        }
    }
    writeln(ans);
}

Measured memory_bytes: 640
function main(input) {
  var x = input
  while (true) {
    if (isPrime(x)) {
      console.log(x)
      break;
    }
    x++;
  }
}
function isPrime(n) {
  for (var i = 2; i <= Math.sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
typedef long long ll;


ll co(int z){
  ll a=pow(3,z)-3*pow(2,z)+3;
  if(a) return a;
  else return 0;
}

bool ju(string ss){
  int z=0;
  for(int i=0;i<ss.size();i++){
    if(ss[i]=='3')z|=1;
    if(ss[i]=='5')z|=2;
    if(ss[i]=='7')z|=4;
  }
  return z==7;
}


int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(n==1||n==2){
    cout<<"0"<<endl;
    return 0;
  }
  ll ans=0;
  for(int i=3;i<n;i++) ans+=co(i);
  vector<char> x={'3','5','7','0'};
  string ss(n,x[0]);
  for(;ss<=s&&ss[0]!='9';){
    if(ju(ss)){
      ans++;
    }
    ss[n-1]+=2;
    for(int i=n-1;i>0;i--){
      if(ss[i]=='9'){
        ss[i]='3';
        ss[i-1]+=2;
      }
      else break;
    }
  }
  cout<<ans<<endl;


  // for(int i=0;i<n;i++){
  //   int z=0;
  //   if(s[i]-'0'>=7)ans+=co(n-1-i)*2;
  //   else if(s[i]-'0'>=5)z++;
  //   else if(s[i]-'0'>=3)z++;
  //   else
  // }

}


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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct UnionFind {
private:
    vector<int> par,depth;
public:
    UnionFind (int n) {
        par.resize(n);
        depth = vector<int>(n,0);
        for (int i = 0;i < n;++i) par[i] = i;
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x,int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (depth[x] < depth[y]) par[x] = y;
        else {
            par[y] = x;
            if (depth[x] == depth[y]) depth[x]++;
        }
    }

    bool same(int x,int y) {
        return find(x) == find(y);
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0;i < m;++i) {
        int x,y,z;
        cin >> x >> y >> z;
        uf.unite(x-1,y-1);
    }
    set<int> st;
    for (int i = 0;i < n;++i) st.insert(uf.find(i));
    cout << st.size() << endl;
}

Measured memory_bytes: 5760
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]

dic={}

for i in a:
  if i in dic.keys():
    dic[i]+=1
  else:
    dic[i]=1
ans=0
nums=list(dic.values())
nums.sort()
ans = 0
for i in range(max(0,len(nums)-k)):
  ans += nums[i]
print(ans)


Measured memory_bytes: 32264
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef string str;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e18;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define pb(x) pop_back(x)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define sum(x) accumulate(all(x),0)
#define pc(x) __builtin_popcount(x)
#define gll greater<ll>()

void solve(){
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
 
  ll ans=-inf;
  if(a>=0&&c>=0) ans=b*d;
  else if(b<=0&&d<=0) ans=a*c;
  else if(b>=0&&a<=0) ans=max({a*c,b*d,b*c,d*a,0ll});
  else if(d>=0&&c<=0) ans=max({a*c,b*d,b*c,d*a,0ll});
  else ans=max({a*c,b*d,b*c,d*a});
  
 cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


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

int main(){
  bool prime[50000];
  prime[0]=prime[1]=false;
  for(int i=2;i<50000;i++){
    prime[i]=true;
  }

  for(int i=2;i*i<50000;i++){
    if(prime[i]){
      for(int j=i*i;j<50000; j+=i){
        prime[j]=false;
      }
    }
  }

  while(true){
    int min,a,cnt;
    cin >> a;

    if(a==0)
      break;
    cnt=0;
    for(int i=2;i<=a/2;i++){
      if(prime[i]&&prime[a-i]){
        cnt++;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <stdio.h>

int main(){
    unsigned long A,B,M;
    unsigned long a[100000], b[100000], mina, minb,inda,indb,mindata;

    unsigned long x, y, c;
    int i, j, k;

    scanf("%ld %ld %ld", &A, &B, &M);
    for (i = 0; i < A;i++){
        scanf("%ld", &a[i]);
        if(i == 0){
            mina = a[i];
            inda = i;
        }else{
            if (mina > a[i])
            {
                mina = a[i];
                inda = i;
            } 
        }
    }
    for (i = 0; i < B; i++)
    {
        scanf("%ld", &b[i]);
        if(i == 0){
            minb = b[i];
            indb = i;
        }
        else
        {
            if (minb > b[i])
            {
                minb = b[i];
                indb = i;
            }
        }

    }

    mindata = mina + minb;
    for (i = 0; i < M; i++)
    {
        scanf("%ld %ld %ld", &x, &y, &c);

        if(mindata > (a[x-1] + b[y-1] - c)){
            mindata = (a[x-1] + b[y-1] - c);
        }
    }

    printf("%ld", mindata);

    return 0;
}


Measured memory_bytes: 1792
def is753?(x)
  x.include?('7') && x.include?('5') && x.include?('3')
end

def dfs(s)
  return 0 if s.to_i > N

  res = is753?(s) ? 1 : 0
  T.each do |t|
    res += dfs(s + t)
  end
  res
end

T = %w(7 5 3)
N = gets.to_i
puts dfs('0')

Measured memory_bytes: 14320
#include <iostream>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int n, a,f;
  vector<pair<int, int> > v;
  
  cin >> n;
  for (int i=0; i<n; i++){
    cin >> a >> f;
    v.push_back(make_pair(-f, a));
  }
  sort(v.begin(), v.end());
  cout << v[0].second << " " << -v[0].first << endl;
  
  return 0;
}
  
  



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
#define ld long double

using namespace std;	

const int N = 211111;

int n;
int a[N];
int ans[N];
int pw[N];
int pref[N], suf[N];
char s[N];

int f(ll x) {
	if (!x) return 0;
	return 1 + f(x % __builtin_popcountll(x));
}

void solve(int mod, int b) {
	if (mod <= 0) return;
	pw[0] = 1 % mod;
	rep(i, 1, n)
		pw[i] = pw[i - 1] * 2 % mod;
	rep(i, 1, n) pref[i] = (pref[i - 1] + !!a[i] * pw[n - i]) % mod;
	per(i, 1, n) suf[i] = (suf[i + 1] + !!a[i] * pw[n - i]) % mod;
	rep(i, 1, n)
		if (a[i] == b) {
			ll x = (pref[i - 1] + suf[i + 1] + pw[n - i] * !a[i]) % mod;
			ans[i] = 1 + f(x);
		}
}
	

int main() {	
	scanf ("%d", &n);
	scanf ("%s", s + 1);
	int z = 0;
	rep(i, 1, n) {
		a[i] = s[i] - '0';
		z += !!a[i];
	}
	solve(z - 1, 1);
	solve(z + 1, 0);
	rep(i, 1, n)
		printf ("%d\n", ans[i]);
	return 0;
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<class T>
T read() {
    T x{};
    cin >> x;
    return x;
}

template<class T>
vector<T> read(int N){
    vector<T> x(N);
    for(int i = 0; i < N; ++i){
        cin >> x[i];
    }
    return x;
}

template<class T>
void write(const T &x){ cout << x << endl; }

int main(){
    auto N = read<ll>(), M = read<ll>();
    auto A = read<ll>(N);
    
    multiset<ll> cost(A.begin(), A.end());
    for(ll i = 0; i < M; ++i){
        auto it = --cost.end();
        auto c = *it;
        cost.erase(it);
        cost.insert(c/2);
    }
    
    ll ans = 0;
    for(auto c : cost){
        ans+= c;
    }
    
    write(ans);
}



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

int main(){
	int a,b,c,x,y;
	long long ans;

	cin >>a >>b >>c >>x >>y;
	
	if(x==0&&b>2*c)ans=c*2*y;
	else if(y==0&&a>2*c)ans=c*2*x;
	else if(a+b>=c*2){
		if(x>=y){
			if((x-y)*2*c<=(x-y)*a)ans=c*2*x;
			else ans=c*2*y+a*(x-y);
		}
		else {
			if((y-x)*2*c<=(y-x)*b)ans=c*2*y;
			else ans=c*2*x+b*(y-x);
		}
	}
	else ans=a*x+b*y;

	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
W = []
for w in range(10):
    w = int(input())
    W.append(w)
K = []
for k in range(10):
    k = int(input())
    K.append(k)
W.sort()
K.sort()
a1 = W[7] + W[8] + W[9]
a2 = K[7] + K[8] + K[9]
print(a1,a2)


Measured memory_bytes: 5600