akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
int main(){
  int n;
  string u,d;
  long long ans=1;
  cin>>n;
  cin>>u;
  cin>>d;
  //true:縦,false:横
  bool type[n];
  REP(i,n){
    if(u[i]==d[i]){
      type[i]=true;
    }else{
      type[i]=false;
    }
    if(i==0){
      if(type[i]){
        ans *= 3;
      }else{
        ans *= 6;
      }
      continue;
    }
    if(!type[i] && u[i]==u[i-1]){
      continue;
    }
    if(!type[i]){
      if(type[i-1]){
        ans = mod(ans*2);
        continue;
      }else{
        ans = mod(ans*3);
        continue;
      }
    }
    if(type[i]){
      if(type[i-1]){
        ans = mod(ans*2);
      }else{
        continue;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

int main() {
  int N, A;
  cin >> N >> A;
  bool ans = false;
  if (N % 500 == 0) {
    ans = true;
  }
  else if (N >= 500 && (N % 500) <= A) {
    ans = true;
  }
  else if (N <= 500 && N <= A) {
    ans = true;
  }
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
zandaka = 1000
kabu = 0
mode = 0

for i in range(N):
  if i == 0:
    if A_list[i + 1] > A_list[i]:
      kabu = 1000 // A_list[i]
      zandaka -= kabu * A_list[i]
      mode = 1
    else:
      continue
  elif i == N - 1:
    zandaka += kabu * A_list[i]
  else:
    if mode == 1:
      if A_list[i] >= A_list[i - 1]:
        if A_list[i] > A_list[i + 1]:
          zandaka += kabu * A_list[i]
          kabu = 0
          mode = 0
        else:
          continue
    else:
      if A_list[i] < A_list[i + 1]:
        kabu = zandaka // A_list[i]
        zandaka -= kabu * A_list[i]
        mode = 1
      else:
        continue

if zandaka >= 1000:
  print(zandaka)
else:
  print(1000)

Measured memory_bytes: 9196
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????? 3

?¬?????±??????????????????????????????????????????¢??????????????\??¬????????§????????????????????°????????????????????????????????????
   +--+
 ???|???|
+--+--+--+--+
|???|???|???|???|
+--+--+--+--+
 ???|???|
   +--+

"""

class Dice:
    T = 0
    S = 1
    E = 2
    W = 3
    N = 4
    B = 5

    """ ????????????????????? """
    def __init__(self): # ?????????????????????
        self.side = [1, 2, 3, 4, 5, 6]
        self.top = 0

    def setDice(self, arr):  # ??¢??????????????????
        self.side = arr[0:6]

    def Turn(self, dir): # ?????????????????¢??????
        s = self.side

        if dir == "N":     # ????????¢??????
            #    Top 0     South 1   East 2    West 3    North 4   Bottom 5
            t = [s[Dice.S],s[Dice.B],s[Dice.E],s[Dice.W],s[Dice.T],s[Dice.N]]
        elif dir == "S": # ????????¢??????
            t = [s[Dice.N],s[Dice.T],s[Dice.E],s[Dice.W],s[Dice.B],s[Dice.S]]
        elif dir == "E": # ??±?????¢??????
            t = [s[Dice.W],s[Dice.S],s[Dice.T],s[Dice.B],s[Dice.N],s[Dice.E]]
        elif dir == "W": # ?\??????¢??????
            t = [s[Dice.E],s[Dice.S],s[Dice.B],s[Dice.T],s[Dice.N],s[Dice.W]]
        elif dir == "L": # ???????????¢
            t = [s[Dice.T],s[Dice.W],s[Dice.S],s[Dice.N],s[Dice.E],s[Dice.B]]
        elif dir == "R": # ???????????¢
            t = [s[Dice.T],s[Dice.E],s[Dice.N],s[Dice.S],s[Dice.W],s[Dice.B]]

        self.side = t
#        print("{0} T0:{1} S1:{2} W2:{3} E3:{4} N4:{5} B5:{6} ".format(dir, self.side[0],self.side[1], self.side[2],self.side[3], self.side[4],self.side[5]))

    def Search(self, tval, sval, dir): # ?????¢??¨?????¢???????????????????????????????????¢???????????????
#        print("{0} T0:{1} S1:{2} W2:{3} E3:{4} N4:{5} B5:{6} ".format(dir, self.side[0],self.side[1], self.side[2],self.side[3], self.side[4],self.side[5]))
    
        if self.side[Dice.E] == tval:
            self.Turn("W")
        elif self.side[Dice.W] == tval:
            self.Turn("E")
        elif self.side[Dice.N] == tval:
            self.Turn("S")
        elif self.side[Dice.S] == tval:
            self.Turn("N")
        elif self.side[Dice.B] == tval:
            self.Turn("N")
            self.Turn("N")

        for i in range(3): # ?????¢?????????????????????????????§????????????
            if self.side[Dice.S] == sval:
                break
            self.Turn("L")
            
        return self.side[dir]

# ?????????
d1num = list(map(int,input().strip().split()))
d2num = list(map(int,input().strip().split()))
d1 = Dice()
d1.setDice(d1num)
d2 = Dice()
d2.setDice(d2num)
v1 = d1.Search(d1.side[Dice.T], d1.side[Dice.S], Dice.E)
v2 = d2.Search(d1.side[Dice.T], d1.side[Dice.S], Dice.E)
if v1 == v2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 7936
from itertools import combinations
import math
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n = int(readline())
m = map(int, read().split())
points = [(x, y) for x, y in zip(m, m)]

if n == 2:
    [(a, b), (c, d)] = points
    print(math.hypot(a - c, b - d) / 2)
    quit()


def center(a, b, c):
    # 外心を計算する
    M = pow(a[0], 2) - pow(b[0], 2) + pow(a[1], 2) - pow(b[1], 2)
    N = pow(a[0], 2) - pow(c[0], 2) + pow(a[1], 2) - pow(c[1], 2)
    Yab = a[1] - b[1]
    Xab = a[0] - b[0]
    Yac = a[1] - c[1]
    Xac = a[0] - c[0]
    d = Yac * Xab - Yab * Xac
    if d == 0:
        return None
    x = (M * Yac - N * Yab) / (2 * d)
    y = - (M * Xac - N * Xab) / (2 * d)
    r = math.hypot(x - a[0], y - a[1])
    return (x, y, r)


centers = []
for a, b, c in combinations(points, 3):
    cen = center(a, b, c)
    if cen is None:
        continue
    centers.append(cen)

for a, b in combinations(points, 2):
    cen = ((a[0] + b[0]) / 2, (a[1] + b[1]) / 2,
           math.hypot(a[0] - b[0], a[1] - b[1]) / 2)
    centers.append(cen)

res = 1000
for cx, cy, cr in centers:
    for x, y in points:
        tr = math.hypot(x - cx, y - cy)
        if tr > cr + 10e-6:
            break
    else:
        if cr < res:
            res = cr
print(res)

Measured memory_bytes: 6388
x, y, z = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(x)]
B = [list(map(int, input().split())) for _ in range(y)]
ans_s = []
ans = []

for i in range(x):
    ans_s = []
    for j in range(z):
        p = 0
        for k in range(y):
            p += A[i][k] * B[k][j]
        ans_s.append(p)
    ans.append((ans_s))

for i in ans:
    print(' '.join([str(v) for v in i]))


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	if(n<=a&&a!=0)
	{
		cout<<n;
	}
	else
	{
		ll g=n/(a+b);
		ll r=n%(a+b);
		ll ans=(g*a)+min(a,r);
		cout<<ans;
	}
}

Measured memory_bytes: 3596
#include<iostream>
#include<iomanip>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


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

	int N;
	cin >> N;
	vector<ll> A(N), B(N);
	REP(i, N) {
		cin >> A[i];
		if (i % 2 == 0) B[0] += A[i];
		else B[0] -= A[i];
	}
	
	REP(i, N - 1) B[i + 1] = 2 * A[i] - B[i];
	REP(i, N) {
		cout << B[i];
		if (i < N - 1) cout << " ";
		else cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long sum = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                for(int k = 1; k <= n; k++){
                    sum += gcd3(i,j,k);
                }
            }
        }
        System.out.println(sum);
    }

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

    public static int gcd3(int x, int y, int z){
        int xy = gcd(x,y);
        return gcd(xy,z);
    }
}

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

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var A = GetInt();
            var B = GetInt();
            var C = GetInt();
            var X = GetInt();

            var ans = 0;
            for(int i = 0; i <= A; i++)
            {
                for(int j = 0; j <= B; j++)
                {
                    for(int k = 0; k <= C; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == X)
                        {
                            ans++;
                        }
                    }
                }
            }

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

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

import sys
sys.setrecursionlimit(10000)

class UnionFind:
    def __init__(self, length):
        # 自身を親として初期化 (-1)。正ならサイズを表す
        self.ary = [-1 for i in range(length)]
    
    def get_root(self, x):
        # rootのidxを求める
        if self.ary[x] < 0:
            return x
        else:
            self.ary[x] = self.get_root(self.ary[x])
            return self.ary[x]

    def is_same(self, x, y):
        return self.get_root(x) == self.get_root(y)

    def unite(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x==y:
            return False
        else:
            if self.ary[x] > self.ary[y]:
                x,y = y,x
            self.ary[x] += self.ary[y]
            self.ary[y] = x
            return True


N, M = map(int, input().split())
X, Y, Z = [0]*M ,[0]*M, [0]*M
uf = UnionFind(N)

for i in range(M):
    X[i],Y[i],Z[i] = map(int, input().split())
    X[i]-=1
    Y[i]-=1

for i in range(M):
    uf.unite(X[i], Y[i])

# rootの数を数える＝グラフの数を数える
s = set()
for i in range(N):
    s.add(uf.get_root(i))

print(len(s))


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

#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>

#define ll long long
#define vl vector<ll>
#define vll vector<vl>

const int INF = 1e9;

ll mod=1000000007;

int main() {
	int n;
	ll k;
	int a[2010];
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	ll ans=0;
	rep(i, n)rep(j, i)
	{
		if(a[j]>a[i]) ans=(ans+k)%mod;
		if(a[i]!=a[j]) ans=(ans+(k*(k-1)/2)%mod)%mod;
	}
	cout << ans << endl;
	return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int n, d, x;
    cin >> n >> d >> x;

    int a, mul, day, c, c_sum = 0;
    rep(0, n) {
        cin >> a;
        mul = 0;
        c = 0;
        day = a * mul + 1;
        while (day <= d) {
            c++;
            mul++;
            day = a * mul + 1;
        }
        c_sum += c;
    }

    cout << (c_sum + x) << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut A: Vec<i64> = sc.vec(N);
    for i in 0..N {
        A[i] -= i as i64+1;
    }
    let mut a = A.clone();
    a.sort();
    let b = a[N/2];
    let mut ans = 0;
    for i in 0..N {
        ans += (A[i] - b).abs();
    }
    println!("{}", ans);
}


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

namespace BeginnerCont143
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine().Split();
            var a = int.Parse(n[0]);
            var b = int.Parse(n[1]);
            var s = a - b * 2;
            if (s < 0)
            {
                s = 0;
            }
            Console.WriteLine(s.ToString());
        }
    }
}


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

#define ll long long

int main(){
    int N;
    int ans=0;
    cin >> N;
    vector<ll>a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define  dl double
#define lld long double
#define v vector
#define loop(i,a,b) for(int i = a; i<= b; i++)
#define Loop(i,a,b) for(int i = a; i< b; i++)
#define inp(i) cin>>i
#define out(i) cout<<i<<endl

using namespace std;

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

    bool found = false;
    ll count = 0;
    while(n--)
    {
        ll x, y;cin>>x>>y;
        if(x==y)
        {
            count++;
        }
        else count = 0;

        if(count==3)
            found = true;

    }

    if(found == true)
    {
        cout<<"Yes\n";
    }
    else
        cout<<"No\n";



return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#pragma O3
#define int long long
using namespace std;
map<int,int> cnt,used;
int n,a[100500],b[100500],tmp,x,ans;
const int mj=2e3+50;
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		x=a[i];
		a[i]=b[i]=1;
		for(int j=2;j<=mj;j++){
			if(x%j==0){
				tmp=0;
				while(x%j==0){
					tmp++;
					x/=j;
				}
				if(tmp%3==1){
					a[i]*=j;
					b[i]*=j*j;
				}
				else if(tmp%3==2){
					a[i]*=j*j;
					b[i]*=j;
				}
			}
		}
		if(x!=1){
			int y=ceil(sqrt(x));
			a[i]*=x;
			if(y*y==x) b[i]*=y;
			else b[i]*=x*x;
		}
		cnt[a[i]]++;
	}
	for(int i=0;i<n;i++){
		if(!used[a[i]]){
			used[a[i]]=used[b[i]]=1;
			if(a[i]==1) ans++;
			else ans+=max(cnt[a[i]],cnt[b[i]]);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 26880
import sys
def primes(m):
    N = range(1,m+1,2)
    r = int(m**.5)
    h = len(N)
    N[0] = 0
    for i in range(h):
        x = N[i]
        if x>r: break
        if x and i+x<h: N[i+x:h:x] = [0]*((h-1-i-x)/x+1)
    x = [2] + filter(None,N)
    return x

PRIMES = primes(50030)
for s in sys.stdin:
    n = int(s)
    for a in PRIMES:
        if a>n: break
        elif a<n: b = a
    print b,a

Measured memory_bytes: 5804
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($format:expr) => (write!(out,$format).unwrap());
        ($format:expr, $($args:expr),+) => (write!(out,$format,$($args),*).unwrap())
    }
    input!{
        i: i64,
        o: i64,
        _t: i64,
        j: i64,
        l: i64,
        _s: i64,
        _z: i64,
    }
    let m = min(i, min(j, l));
    let mut ans = 2 * ((i - m) / 2 + (j - m) / 2 + (l - m) / 2) + 3 * m;
    if m >= 1 {
        let m = m - 1;
        ans = max(ans, 2 * ((i - m) / 2 + (j - m) / 2 + (l - m) / 2) + 3 * m);
    }
    puts!("{}\n", ans + o);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    unsigned long long int n,k,h,ans=0;
    cin>>n>>k;

    vector<int> v;
    for(int i=0; i<n; i++)
    {
        cin>>h;
        v.push_back(h);
        ans+=h;
    }
    sort(v.begin(),v.end(),greater<int>());
    k=min(k,n);
    for(int i=0; i<k; i++)
    {
        ans-=v[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
int ax,ay,bx,by,cx,cy;
P A,B,C;
double sinA,cosA,sinB,cosB,sinC,cosC;

double funcC(double ra){
  double L=0,R=10000,M;
  for(int i=0;i<50;i++){
    M=(L+R)/2.0;
    if( M/sinC*cosC + ra/sinA*cosA + sqrt( 4.0*ra*M ) < abs(A-C) ) L=M;
    else R=M;
  }
  return L;
}

double funcB(double ra){
  double L=0,R=10000,M;
  for(int i=0;i<50;i++){
    M=(L+R)/2.0;
    if( M/sinB*cosB + ra/sinA*cosA + sqrt( 4.0*ra*M ) < abs(A-B) ) L=M;
    else R=M;
  }
  return L;
}

bool check(double ra){
  double rb=funcB(ra);
  double rc=funcC(ra);
  if( rb/sinB*cosB + rc/sinC*cosC + sqrt( 4.0*rb*rc ) < abs(C-B) ){
    return true;
  }else{
    return false;
  }
}

void calc(P AB,P AC,double &Sin,double &Cos){
  AB/=abs(AB);AC/=abs(AC);
  AB=(AB+AC)*0.5;
  Sin = abs(imag(AB*conj(AC)))/abs(AB);
  Cos = real(AB*conj(AC))/abs(AB);
}

int main(){
  while(1){
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    if(ax==0&&ay==0&&bx==0&&by==0&&cx==0&&cy==0)break;
    A=P(ax,ay),B=P(bx,by),C=P(cx,cy);
    calc(B-A,C-A,sinA,cosA);
    calc(A-B,C-B,sinB,cosB);
    calc(A-C,B-C,sinC,cosC);
    double L=0,R=10000,M;
    for(int i=0;i<50;i++){
      M=(L+R)/2.0;
      if(check(M))R=M;
      else L=M;
    }
    printf("%.10f %.10f %.10f\n",L,funcB(L),funcC(L));
  }
  return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = Integer.parseInt(sc.nextLine());
            if (n < 1) break;
            int[] sum = new int[2];
            for (int i = 0; i < 2; i++) {
                sum[i] = 0;
            }
            for (int i = 0; i < n; i++) {
                String[] s = sc.nextLine().split(" ");
                int[] num = new int[2];
                for (int j = 0; j < 2; j++) {
                    num[j] = Integer.parseInt(s[j]);
                }
                if (num[0] < num[1]) {
                    sum[1] += num[0] + num[1];
                } else if (num[1] < num[0]) {
                    sum[0] += num[0] + num[1];
                } else {
                    sum[0] += num[0];
                    sum[1] += num[1];
                }
            }
            System.out.println(sum[0] + " " + sum[1]);
        }
    }
}

Measured memory_bytes: 65504
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005

int main() {

    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);

    int ans = 0;

    for(int i=0; i<=105; i++) {

        int x = i*d;

        if((x>=l) && (x<=r)) {
            ans++;
        }
    }

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


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

int main(){
    while(1){
        int a, b;
        cin >> a >> b;
        if((a!= 0)&&(b!= 0)){
            vector<string>k(b, "#");
            for(int i = 0; i < b; i++){
                cout << k[i];
            }
            cout << endl;
            
          vector<vector<string> >l(a-2, vector<string>(b, "."));
            
          for(int i = 0; i < a-2; i++){
                l[i][0] = "#";
                l[i][b-1] = "#";
            }
          
          for(int i = 0; i < a-2; i++){
                for(int j = 0; j < b; j++){
                    cout << l[i][j];
                }
                cout << endl;
            }
            
            for(int i = 0; i < b; i++){
                cout << k[i];
            }
            
          cout << endl;
          cout << endl;
        }else{
            break;
        }
     }
}


Measured memory_bytes: 3288
#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>;

bool is_prime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrt_num = sqrt(num);
    for (int i = 3; i <= sqrt_num; i += 2) {
        if (num % i == 0)
            return false;
    }

    return true;
}

int main() {
    int X; cin >> X;
    while (!is_prime(X))
        X++;

    cout << X << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

const int MAX = 5e5;
const int INF = INT_MAX;

void merge(int*, int, int, int);
void mergesort(int*, int, int);

int ans;

int main(){
  int n, i, a[MAX];

  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }

  mergesort(a, 0, n);

  for(i = 0 ; i < n ; i++){
    printf("%d%c" ,a[i], i != n-1 ? ' ':'\n');
  }
  printf("%d\n" ,ans);

  return 0;
}

void merge(int a[], int left, int mid, int right){
  int n1 = mid - left, n2 = right - mid;
  int L[n1+1], R[n2+1], i, j, k;

  for(i = 0 ; i < n1 ; i++){
    L[i] = a[left + i];
  }

  for(i = 0 ; i < n2 ; i++){
    R[i] = a[mid + i];
  }

  L[n1] = R[n2] = INF;

  for(i = 0, j = 0, k = left ; k < right ; k++, ans++){
    if(L[i] <= R[j]){
      a[k] = L[i++];
    }else{
      a[k] = R[j++];
    }
  }
}

void mergesort(int a[], int left, int right){
  int mid;

  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(a, left, mid);
    mergesort(a, mid, right);
    merge(a, left, mid, right);
  }
}

Measured memory_bytes: 4504
# https://atcoder.jp/contests/abc144/tasks/abc144_b
n = int(input())
o = 'No'
if n <=81:
    for i in range(1,10):
        r = n%i
        q = n//i
        if r == 0 and 1<=q<= 9:
            o = 'Yes'
            break
print(o)

Measured memory_bytes: 2940
n, m = gets.chomp.split(" ").map(&:to_i)
count = 0
if n == 1
  if m == 1
    count = 1
  else
    count = m - 2
  end
elsif m == 1
  count = n - 2
elsif
  count = (n-2) * (m-2)
end

p count

Measured memory_bytes: 1788
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a//b)

Measured memory_bytes: 7656
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)

typedef long long LL;
const int N=20005;

LL abs(LL x) {
	return (x<0)?(-x):(x);
}

LL gcd(LL x,LL y) {
	return !y?x:gcd(y,x%y);
}

int main(void) {
	int n; LL m,ans; scanf("%d%lld",&n,&m);
	rep(i,1,n) {
		LL x; scanf("%lld",&x);
		if (i==1) ans=abs(x-m);
		else ans=gcd(ans,abs(x-m));
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimensi0n, default_val) assert(type(default_val) ~= 'table') local n=dimensi0n local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
--
local N, X, T = read.nnn()
local set = (N // X)
if N % X ~= 0 then
    set = set + 1
end
print(set * T)

Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,count=0;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		if(n%i==0)
			count+=n/i-1;
		else
			count+=n/i;
	}
	cout<<count;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N; cin >> N;
  vector<ll> A(N, 0);
  vector<ll> B(N, 0);
  vector<pair<ll, ll> > AB(N, pair<ll, ll>());
  REP(i, N){
    ll a, b; cin >> a >> b;
    A[i] = a; B[i] = b;
    AB[i] = {a + b, i};
  }
  sort(AB.begin(), AB.end(), greater<pair<ll, ll> >());
  ll a = 0, b = 0;
  for(ll i = 0; i < N - 1; i += 2){
    a += A[AB[i].second];
    b += B[AB[i+1].second];
  }
  if(N % 2 != 0){
    a += A[AB[N-1].second];
  }
  cout << a - b << endl;
}

Measured memory_bytes: 3456
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }

const int MAX = 100000;
int cnt[MAX];
int n;

void init()
{
	memset(cnt, 0, sizeof cnt);

	cin >> n;
	REP(i, n)
	{
		int tmp;
		cin >> tmp;
		++cnt[tmp - 1];
	}
}

void declare()
{
	int ans = 0;
	REP(i, MAX) ans += cnt[i];
	cout << ans << endl;
}

int main()
{
	init();

	REP(a, MAX)
	{
		if (cnt[a] > 2)
		{
			if (cnt[a] & 1) cnt[a] = 1;
			else cnt[a] = 2;
		}
		
		if (cnt[a] == 2)
		{
			bool flag = true;
			int rem = -1;
			for (int b = a + 1; b < MAX; b++)
			{
				if (cnt[b] > 1)
				{
					flag = false;
					rem = b;

					if (!(cnt[b] & 1))
					{
						--cnt[b];
						--cnt[a];
						break;
					}
				}

			}

			if (flag)
			{
				int ans = 0;
				REP(i, MAX) ans += cnt[i];
				cout << ans - 2 << endl;
				return 0;
			}
			else if (cnt[a] == 2)
			{
				--cnt[a];
				--cnt[rem];
			}
		}
	}

	declare();
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, x, y, com, ext,tot=0;
    scanf("%d%d%d%d%d", &a, &b, &c, &x, &y);
    if (y > x)
    {
        int t = x;
        x = y;
        y = t;
        t = a;
        a = b;
        b = t;
    }
    com=y;ext=x-y;
    if(2*c<a+b)tot+=com*c*2;else tot+=com*(a+b);
    if(2*c<a)tot+=ext*2*c;else tot+=ext*a;\
    printf("%d",tot);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX_N 100000
using namespace std;

int N, K, x[MAX_N];
int main() {
	cin >> N >> K;
	for(int i = 0; i < N; ++i)
		cin >> x[i];
	
	int x0 = distance(x, lower_bound(x, x + N, 0));
	
	int res = 10e8;
	for(int i = 0; i <= K; ++i) {
		int left = x0 - i;
		int right = x0 + (K - i) - 1;
		if(left < 0 || right >= N)
			continue;
		
		int cur = abs(x[left] - x[right]) + min(abs(x[left]), abs(x[right]));
		res = min(res, cur);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, k;
    cin >> n >> k;
    ll ans = k;
    rep(i, n-1) ans *= (k-1);
    cout << ans;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


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

int main() {
    //freopen("../input.txt", "r", stdin);
    int N;
    cin >> N;
    string s;
    cin >> s;
    int counter = 0;
    for (int i = 0; i < N; ++i) {
        if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
            counter++;
            i=i+2;
        }else{
            continue;
        }
    }
    cout << counter;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 3e3+5;
const lli INF = 1e18;
const lli MOD = 1e9+7;

vi m;
vi primes(1,2);
vector<vector<ld>>nk;
void sieve(){
	m = vi(N+1,0);
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	nk =vector<vector<ld>>(N,vector<ld>(N,0.0));
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

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

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

lli SUM(lli a, lli b, lli mod=MOD){
	return (a+b+mod)%mod;
}

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

// ---- コーディングはここから！ ('-')7

void solve(){
 int n; cin>>n;
 vvi v(n,vi(n)); fore(i,0,n)fore(j,0,n)cin>>v[i][j];
 vvl dp(n,vl(1<<n,-1));
 auto f=[&](auto f, int x, int mask)->lli{
	 if(x==n)return mask==(1<<n)-1;
	 if(dp[x][mask]!=-1)return dp[x][mask];
	 lli res = 0;
	 fore(i,0,n)if(v[x][i] and ((1<<i)&mask)==0)res=SUM(res,f(f,x+1,mask|(1<<i)));
	 return dp[x][mask]=res;
 };
 cout<<f(f,0,0)<<ENDL;
}

int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 363808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int c[3][3];

  rep(j,3)
    rep(i,3)
    cin >> c[i][j];

  FOR(i,0,100){
    int a[3]={0};
    int b[3]={0};
    a[0] = i;
    rep(j,3){
      b[j] = c[0][j] - a[0];
    }
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool same=true;
    rep(j,3){
      rep(i,3){
        int d = a[i]+b[j];
        if(d!=c[i][j]) same=false;
      }
    }
    if(same==true){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

f(A,A,B) :- A \= B.
f(A,B,A) :- A \= B.
f(B,A,A) :- A \= B.

main:-
    get_number(A),
    get_number(B),
    get_number(C),
    (f(A,B,C)) -> writeln("Yes") ; writeln("No").


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

int main(){
  int A,B;
  string S;
  cin>>A>>B>>S;
  for(int i=0;i<A+B+1;i++){
    if(S[i]=='-'){
      if(i!=A){
        cout<<"No"<<endl;
        return 0;
      }
    }else if(i==A){
        cout<<"No"<<endl;
        return 0;
      }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  prllf("%d",x);
#define pl(x)  prllf("%lld",x);
#define pf(x)  prllf("%.10lf",x);
#define ps(x)  prllf("%s",x);
#define en() prllf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define mod 1000000007
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

ll prime[1000000];bool visprime[1000000];
void sieve(){int k=0;for(int i=2;i*i<=1000000;i++) {if(visprime[i]==false) {for(int j=i*i;j<=1000000;j+=i){ visprime[j]=true;}}}for(int i=2;i<=1000000;i++){if(visprime[i]==false) prime[k++]=i;}}

map<ll,ll>m;
vector<ll>pf[100000+5];

ll powll(ll n,ll m){
   return m?((m&1)?n:1)*powll(n*n,m>>1):1;
}

void primefactor(ll x,ll indx)
{
    //ll temp=x;
    for(int i=0;prime[i]*prime[i]<=x;i++)
    {
        ll p=prime[i];
        if(x%p==0)
        {
            ll cnt=0;
            while(x%p==0)
            {
                //if(x%p!=0) break;
                x/=p;
                cnt++;
            }
             m[p]=max(m[p],cnt);

            pf[indx].pb(p);


        }

        //if(x/p==0) break;
    }
    if(x>1) pf[indx].pb(x);
    m[x]=max(m[x],(ll)1);

}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}
ll visit[1000000];

int main()
{

 sieve();
 ll n;
 cin>>n;
 ll arr[n];
 //ll Md=1000000007;

 for(int i=0;i<n;i++)
 {
     cin>>arr[i];
     primefactor(arr[i],i);


 }

 //cout<<m[3]<<" "<<m[2]<<endl;
 //cout<<endl;
 ll ans=1;
 // if(n==1) return cout<<1<<endl,0;

  for(ll i=0;i<n;i++)
  {
      for(ll j=0;j<pf[i].size();j++)
      {
          ll temp=pf[i][j];
          if(visit[temp]==0){ans*=powll(temp,m[temp])%mod;
          visit[temp]++;
          }
          ans%=mod;

      }
     // cout<<ans<<endl;
      //ans=(ans%mod+(ans/arr[i])%mod)%mod;

  }
    ll sum=0;
  for(ll i=0;i<n;i++)
  {
      sum+=ans*modinv(arr[i],mod);
      sum%=mod;
  }


  cout<<sum<<endl;













}


Measured memory_bytes: 12928
a,b = map(int,input().split())

if a>0:
    print("Positive")
elif a == 0:
    print("Zero")
else:
    if b < 0:
        if (b-a)%2 == 0:
            print("Negative")
        else:
            print("Positive")
    else:
        print("Zero")



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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d)<<endl;
    return 0;
}


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

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

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

    // 入力
    int n, a;
    cin >> n >> a;

    // 処理
    // if (n % 500 <= a) {
    //     cout << "Yes" << endl;
    // } else {
    //     cout << "No" << endl;
    // }
    cout << ((n % 500 <= a) ? "Yes" : "No") << endl;

    // 出力

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	static int INF = Integer.MAX_VALUE;
	static int[] a, dp, ans;
	static List<Integer>[] list;
	static int max;
	
	static int lower_bound(int[] a, int key) {
		if(a[a.length-1] < key)
			return a.length;
		int lb = 0, ub = a.length-1, mid;
		do {
			mid = (ub+lb)/2;
			if(a[mid] < key)
				lb = mid + 1;
			else
				ub = mid;
		}while(lb < ub);
		return ub;
	}
	
	
	static void dfs(int v, int p) {
		int id = lower_bound(dp, a[v]);
		int p_id = id;
		int val = dp[id];
		int p_max = max;
		dp[id] = a[v];
		ans[v] = max = Math.max(max, id);
		for(int i : list[v])
			if(i != p)
				dfs(i, v);
		dp[p_id] = val;
		max = p_max;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		a = new int[N];
		list = new ArrayList[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			list[i] = new ArrayList<>();
		}
		for(int i = 1; i < N; i++){
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			list[u].add(v);
			list[v].add(u);
		}
		dp = new int[N+1];
		Arrays.fill(dp, INF);
		dp[0] = 0;
		ans = new int[N];
		dfs(0, 0);
		StringBuilder out = new StringBuilder();
		for(int i = 0; i < N; i++)
			out.append(ans[i] + "\n");
		System.out.print(out);
	}

}


Measured memory_bytes: 97852
n = int(input())
a = [0]
temp = list(map(int, input().split()))
for i in range(n):
    temp[i] -= (i + 1)
temp.sort()
a.extend(temp)

aSum = [0] * (n + 1)
aSum[0] = a[0]
for i in range(1, n+1):
    aSum[i] = aSum[i - 1] + a[i]

minSad = float('inf')
for i in range(1, n + 1):
    b = a[i]
    tempL = b * i - (aSum[i] - aSum[0])
    tempR = (aSum[n] - aSum[i]) - b * (n - i) 
    minSad = min(minSad, tempL + tempR)

print(minSad)

Measured memory_bytes: 25712
#include<stdio.h>
int main (void){
    int n,i,j,a[201]={0},b[201]={0},c[201]={0},x,ans;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            if(a[i]==a[j]){
                a[j]=0;
                x=1;
            }
        }
        if(x==1){
            x=0;
            a[i]=0;
        }
        for(j=i+1;j<=n;j++){
            if(b[i]==b[j]){
                b[j]=0;
                x=1;
            }
        }
        if(x==1){
            x=0;
            b[i]=0;
        }
        for(j=i+1;j<=n;j++){
            if(c[i]==c[j]){
                c[j]=0;
                x=1;
            }
        }
        if(x==1){
            x=0;
            c[i]=0;
        }
    }
    for(i=1;i<=n;i++){
        ans=a[i]+b[i]+c[i];
        printf("%d\n",ans);
    }
return 0;
}

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

struct Data{
	int y, x, dep;
	Data(){
		dep = 0;
	}
};

int main(){
	int n, x_sp[10], y_sp[10];
	Data s;
	int nx_phon[13] = { 0, 1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -1 },
		ny_phon[13] = { -2, -2, -1, 0, 1, 2, 2, 2, 1, 0, -1, -2 };
	int nx_sp[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 },
		ny_sp[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };

	while (cin >> s.x >> s.y, s.x != 0 || s.y != 0){
		cin >> n;
		for (int i = 0; i < n; i++){
			cin >> x_sp[i] >> y_sp[i];
		}

		queue<Data> q;
		q.push(s);
		Data q_c, q_d;
		int px_phon, py_phon, px_sp, py_sp, ans = false;
		bool frst = true;
		while (!q.empty()){
			bool memo[10][10] = {};
			q_c = q.front();
			q.pop();
			for (int i = 0; i < 12; i++){
				px_phon = q_c.x + nx_phon[i];
				py_phon = q_c.y + ny_phon[i];
				if (px_phon < 0 || 9 < px_phon || py_phon < 0 || 9 < py_phon) continue;
				for (int j = 0; j < 9; j++){
					px_sp = x_sp[q_c.dep] + nx_sp[j];
					py_sp = y_sp[q_c.dep] + ny_sp[j];
					if (px_sp < 0 || 9 < px_sp || py_sp < 0 || 9 < py_sp) continue;
					if (memo[px_sp][py_sp])continue;
					if (px_phon == px_sp && py_phon == py_sp){
						//printf("%d",q_c.dep);
						if (q_c.dep == n - 1){
							ans = true;
							goto END;
						}
						memo[px_sp][py_sp] = true;
						q_d.x = px_sp; q_d.y = py_sp; q_d.dep = q_c.dep + 1;
						if (q_d.dep == n){
							q_d.dep = 0;
							frst = false;
						}
						q.push(q_d);
						break;
					}
				}
			}
		}
		END:
		if (ans) printf("OK\n");
		else printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 1176
data = [
        [[0 for k in range(10)] for j in range(3)] for i in range(4)
        ]

count = int(input())

for x in range(count):
   (b,f,r,v) = [int(i) for i in input().split()]
   data[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        print(' ',end='')
        for r in range(10):
            if r == 9:
                print(data[b][f][r], end='')
            else:
                print(data[b][f][r], '', end='')
        print()

    if b == 3:
        break
    for x in range(20):
        print('#',end='')
    print()

Measured memory_bytes: 6728