akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> W(N);
    ll wa = 0;
    rep(i,N){
        cin >> W[i];
        wa += W[i];
    }
    ll now = 0,ans = INF;
    rep(i,N){
        chmin(ans,abs(wa - 2 * now));
        now += W[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int n, k;
	int a[1100];
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < k; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
int main(void){
  int a,b,c,d,e,f,g,h,i,j;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  scanf("%d%d%d%d",&e,&f,&g,&h);
  i=a+b+c+d;
  j=e+f+g+h;
  if(i<j){
    printf("%d\n",j);
  }
  if(i>j){
    printf("%d\n",i);
  }
  if(i=j){
    printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<queue> 
#include<map>
#include<set>
#include<stack>
#define debug(a) cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll; 
typedef pair<int, int> P;
const int N = 1000000 + 5;
set<ll> st;
bool p[N];
void init(){
     for(int i = 2; i < N; i ++) p[i] = true;//先全部初始化为质数 
     for(int i = 2; i < N; i ++){
         if(p[i]){//如果i是质数 
             for(int j = 2*i; j < N; j += i){//从i的两倍开始的所有倍数 
                 p[j] = false; 
             }
         }
     }
}
ll pow_mod(ll a, ll b, ll p){//a的b次方求余p 
      ll ret = 1;
      while(b){
          if(b & 1) ret = (ret * a) % p;
          a = (a * a) % p;
          b >>= 1;
      }
      return ret;
}
ll Fermat(ll a, ll p){//费马求a关于b的逆元 
         return pow_mod(a, p-2, p);
}
ll gcd(ll a, ll b)
{
 	if (b == 0)	return a;
 	return gcd(b, a % b);
}
ll n, a[10005], mod = 1000000007, s, ans;
ll	prime[3000]= {0}, num = 0, pri[3000];
ll number(ll &x, ll b)
{
	ll an = 0;
	while (1)
	{
		if (x % b == 0 && x)
		{
			x /= b;
			
		}
		else
			break;
		an++;
	}
	if (x > 1000 && p[x] && !st.count(x))
	{
		st.insert(x);
		s = (s * x) % mod;
	}
	return an;
}
void get(ll a)
{
	for (int i = 0; i < num; i++)
	{
		if (a % prime[i] == 0)
		{
			pri[i] = max(pri[i], number(a, prime[i]));
		}	
	}
}
ll mul(ll a, ll b)
{
	ll ff[12], len = 0, sum = 0;
	while (a)
	{
		ff[len++] = a % 10;
		a /= 10;
	}
	for (int i = len - 1; i >= 0; i--) 
	{
		sum *= 10;
		sum = (sum + ff[i] * b) % mod;
	}
	return sum;
}
int main()
{
	init(); 
	//debug(2026 * 523);
	for (int i = 2; i < 1000; i++)
	{
		if (p[i])
		{
			prime[num++] = i;
		}
	}
	//debug(num);
	//debug((ll)1000000*999999%mod*(ll)999998/2%mod); 
	while (~scanf("%lld", &n))
	{
		memset(pri, 0, sizeof(pri));
		st.clear();
		s = 1;
		ans = 0;
		for (int i = 0; i < n; i++)
		{
			scanf("%lld", &a[i]);
			/*if (i == 0)
			{
				s = a[i];
				continue;
			}*/
			//ll x = gcd(max(s, a[i]), min(s, a[i]));
			//s = s * a[i] % mod * Fermat(x, mod) % mod;
			get(a[i]);
			if(a[i] > 1000 && p[a[i]] && !st.count(a[i]))	
			{
				st.insert(a[i]);
				s = s * a[i] % mod;
			}	
		}
		for (int i = 0; i < num; i++)
		{
			if (pri[i])
				s = s * (pow_mod(prime[i], pri[i], mod)) % mod;
		}
		/*for (set<ll>::iterator it = st.begin(); it != st.end(); it++)
		{
			s = s * (*it) % mod;
		}*/
		//debug(s);
		for (int i = 0; i < n; i++)
		{
			ans = (ans + s * Fermat(a[i], mod) % mod) % mod;
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextInt()
	b := nextInt()
	for i := 1; i < 2600; i++ {
		if i*8/100 == a && i*10/100 == b {
			fmt.Println(i)
			return
		}
	}
	fmt.Println("-1")
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

signed main(){
	int n,m;
	cin >> n >> m;
	vector<int> v(n);
	for (int i=0; i<n; ++i){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	vector<pair<int,int>> v2;
	for (int i=0; i<m; ++i){
		int a,b;
		cin >> a >> b;
		v2.emplace_back(b,a);
	}
	sort(v2.begin(),v2.end());
	reverse(v2.begin(),v2.end());
	int idx=0;
	bool op=false;
	for (auto& i:v2){
		while (i.second){
			if (idx >= n or v[idx] > i.first){
				op=true;
				break;
			}
			v[idx]=i.first;
			++idx;
			i.second--;
		}
		if (op) break;
	}
	int sum=0;
	for (auto& i:v) sum += i;
   cout << sum;
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

struct UF{
    vector<int> par;
    vector<int> sz;
    void init(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};


signed main(){
    int n, k, l;
    cin >> n >> k >> l;
    UF u, s;
    u.init(n);
    s.init(n);
    rep(i, 0, k){
        int p, q;
        cin >> p >> q;
        p--; q--;
        u.unite(p, q);
    }
    rep(i, 0, l){
        int p, q;
        cin >> p >> q;
        p--; q--;
        s.unite(p, q);
    }
    map<P, int> mp;
    rep(i, 0, n){
        mp[P(u.find(i), s.find(i))]++;
    }
    rep(i, 0, n){
        cout << mp[P(u.find(i), s.find(i))] << endl;
    }
}

Measured memory_bytes: 18176
class Node():
    def __init__(self, key = None ,left =None ,right = None):
        self.key_value = key
        self.left = left
        self.right = right

class BST():
    def __init__(self):
        self.root = None

    def insert(self, data):
        n = self.root
        if n == None:
            self.root = Node(data)
            return
        else:
            while True:
                entry = n.key_value
                if data < entry:
                    if n.left is None:
                        n.left = Node(data)
                        return
                    n = n.left
                elif data > entry:
                    if n.right is None:
                        n.right = Node(data)
                        return
                    n = n.right
                else:
                    n.data = data
                    return

    def find(self,data):
        n = self.root
        if n == None:
            return False
        else:
            lst = []
            lst.append(n)
            while len(lst) > 0:
                node = lst.pop()
                if node.key_value == data:
                    return True
                if node.left != None and data < node.key_value:
                    lst.append(node.left)
                if node.right != None and data > node.key_value:
                    lst.append(node.right)
        return False

    def inorder(self,node):
        if node is None:
            return
        else:
            self.inorder(node.left)
            print(' {}'.format(node.key_value),end='')
            self.inorder(node.right)

    def preorder(self,node):
        if node is None:
            return
        else:
            print(' {}'.format(node.key_value),end='')
            self.preorder(node.left)
            self.preorder(node.right)

if __name__ == "__main__":
    n = int(input())

    bst = BST()
    for i in range(n):
        o = input().split()

        if o[0] == 'insert':
            bst.insert(int(o[1]))
        elif o[0] == 'print':
            bst.inorder(bst.root)
            print()
            bst.preorder(bst.root)
            print()
        elif o[0] == 'find':
            if bst.find(int(o[1])):
                print('yes')
            else:
                print('no')



Measured memory_bytes: 85296
let x, y =
  let l = stdin.ReadLine().Split(' ') |> Array.map int
  l.[0], l.[1]

let ans =
  if y = 0 then
    if x < 0 then (abs x) else (abs x) + 1
  else
    if (abs x) = (abs y) then
      1
    elif x = 0 then
      if y > 0 then
        y
      else
        -y + 1
    elif x < -(abs y) then
      if y > 0 then
        abs (-(abs y) - x) + 1
      else
        abs (-(abs y) - x)
    elif x > abs y then
      if y > 0 then
        abs (-(abs y) - (-x)) + 2
      else
        abs (-(abs y) - (-x)) + 1
    elif x < 0 then
      if y > 0 then
        abs (abs y - abs x) + 1
      else
        abs (abs y - abs x) + 2
    else
      if y > 0 then
        abs (abs y - abs x)
      else
        abs (abs y - abs x) + 1

ans |> stdout.WriteLine

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;

template <int32_t MOD>
struct mint {
    int32_t data;
    mint() = default;
    mint(int32_t value) : data(value) {}
    inline mint<MOD> operator + (mint<MOD> other) const { int32_t c = this->data + other.data; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->data += other.data; if (this->data >= MOD) this->data -= MOD; return *this; }
};

constexpr int MOD = 1e9 + 7;
enum state_t {
    S,
    S0,
    S01,
    S00,
    S1,
    S10,
    S100,
    S11,
    STATE_SIZE,
};
int solve(string const & s) {
    int n = s.length();
    vector<array<mint<MOD>, STATE_SIZE> > dp(n + 1, array<mint<MOD>, STATE_SIZE>());
    dp[0][S] = 1;
    REP (i, n) {
        if (s[i] == '0' or s[i] == '?') {
            dp[i + 1][S0  ] += dp[i][S   ];
            dp[i + 1][S00 ] += dp[i][S0  ];
            dp[i + 1][S0  ] += dp[i][S01 ]; //
            dp[i + 1][S0  ] += dp[i][S00 ];
            dp[i + 1][S10 ] += dp[i][S1  ];
            dp[i + 1][S100] += dp[i][S10 ];
            dp[i + 1][S10 ] += dp[i][S100];
            dp[i + 1][S11 ] += dp[i][S11 ];
        }
        if (s[i] == '1' or s[i] == '?') {
            dp[i + 1][S1  ] += dp[i][S   ];
            dp[i + 1][S01 ] += dp[i][S0  ];
            dp[i + 1][S1  ] += dp[i][S01 ];
            dp[i + 1][S0  ] += dp[i][S00 ]; //
            dp[i + 1][S11 ] += dp[i][S1  ];
            dp[i + 1][S1  ] += dp[i][S10 ];
            dp[i + 1][S10 ] += dp[i][S100]; //
            dp[i + 1][S11 ] += dp[i][S11 ];
        }
    }
    return (dp[n][S1] + dp[n][S11]).data;
}

int main() {
    string s; cin >> s;
    cout << solve(s) << endl;
    return 0;
}


Measured memory_bytes: 9988
#include<iostream>
#include<vector>
#include<string>

int main(){
    int N;
    std::cin >> N;
    std::vector<int> L(N);
    int sum = 0;
    int maxL = 0;
    for(int i = 0; i < N; i++){
        std::cin >> L[i];
        sum += L[i];
        maxL = std::max(maxL, L[i]);
    }
    if(sum - maxL > maxL){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.List (unfoldr, break)

readInts :: B.ByteString -> [Int]
readInts bs = unfoldr (B.readInt . B.dropWhile (== ' ')) bs

main :: IO ()
main = do
    [n, k] <- readInts <$> B.getLine
    -- as <- readInts <$> B.getLine
    B.getLine
    print $ (n - 1 + k - 1 - 1) `div` (k - 1)

Measured memory_bytes: 1660
s=int(input())
def f(a):
    if a%2:
        return 3*a+1
    else:
        return a//2
value=(s,)
a=s
for i in range(2,1000000):
    a=f(a)
    if a in value:
        print(i)
        break
    value += (a,)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int K = scan.nextInt();
        int[] x = new int[N];
        for (int i = 0; i < N; i++) {
            x[i] = scan.nextInt();
        }
        long answer = Long.MAX_VALUE;
        for(int i = 1; i <= N-K+1; i++) {
            answer = Math.min(answer, Math.abs(x[i-1])+x[i+K-2]-x[i-1]);
            answer = Math.min(answer, Math.abs(x[i+K-2])+Math.abs(x[i+K-2]-x[i-1]));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 50032
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <string>

#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i+=2) {
		int cnt = 0;
		for (int j = 1; j <= i; j++) {
			if (i%j == 0) cnt++;
		}
		if (cnt == 8) ans++;
	}cout << ans;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }
        

        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            const long INF = long.MaxValue;
         
            var input =Reads();
            var w = input[0];
            var h = input[1];
            var n = input[2];
            var x = new long[n];
            var y = new long[n];
            var a = new long[n];
            long minx = INF;
            long miny = INF;
            long maxx = -1;
            long maxy = -1;
            for (int i = 0; i < n; i++)
            {
                input = Reads();
                if (input[2] == 1 && maxx < input[0])
                    maxx = input[0];
                else if (input[2] == 2 && input[0] < minx)
                    minx = input[0];
                else if (input[2] == 3 && maxy < input[1])
                    maxy = input[1];
                else if (input[2] == 4 && input[1] < miny)
                    miny = input[1];
            }
            if (minx == INF) minx = w;
            if (miny == INF) miny = h;
            if (maxx == -1) maxx = 0;
            if (maxy == -1) maxy = 0;
            if (maxx- minx < 0 && maxy - miny < 0)
                Console.WriteLine((maxx - minx)* (maxy - miny));
            else
                Console.WriteLine(0);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int main(void){
    int a,b,c,N;
    int i;
    int tmp;
    
    scanf("%d",&N);
    
    for(i=0; i<N; i++){
        scanf("%d %d %d",&a,&b,&c);
        if(a>b){
            tmp = a;
            a = b;
            b = tmp;
        }
        if(b>c){
            tmp = b;
            b = c;
            c = tmp;
        }
        if(a>b){
            tmp = a;
            a = b;
            b = tmp;
        }
        
        if(a*a+b*b == c*c) puts("YES");
        else puts("NO");
    }
    
    return 0;
}

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

int main(){
    int a,b,c,d,x;
    cin>>a>>b>>c>>x;
    int 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++;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        System.out.println(Math.min(n*a, b));
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 21204
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
  	Scanner in = new Scanner(System.in);

  	int N = in.nextInt();
  	int K = in.nextInt();
  	int a[] = new int[N];
  	int sum = 0;

  	for(int cnt = 0; cnt < N;cnt++){
  		a[cnt] = in.nextInt();
  	}

  	for(int cnt = 0; cnt < N; cnt++){
  		int A = a[cnt];
  		int B = K - a[cnt];
  		if( A < B ){
  			sum = sum + A;
  		}
  		else{
  			sum = sum + B;
  		}
  	}

  	System.out.println(sum * 2);
  }


}

Measured memory_bytes: 21844
#12:40
n = int(input())
a1,a2,a3 = map(int,input().split())
b1,b2,b3 = map(int,input().split())
dp = [0] * (n+1)
for i in range(1,n+1):
  tmp = dp[i-1]+1
  if i-a1 >= 0:
    if dp[i-a1]+b1 > tmp:
      tmp = dp[i-a1]+b1
  if i-a2 >= 0:
    if dp[i-a2]+b2 > tmp:
      tmp = dp[i-a2]+b2
  if i-a3 >= 0:
    if dp[i-a3]+b3 > tmp:
      tmp = dp[i-a3]+b3
  dp[i] = tmp
m = dp[-1]
#print(dp)
#print(m)
dp = [0] * (m+1)
for j in range(1,m+1):
  tmp = dp[j-1]+1
  if j-b1 >= 0:
    if dp[j-b1]+a1 > tmp:
      tmp = dp[j-b1]+a1
  if j-b2 >= 0:
    if dp[j-b2]+a2 > tmp:
      tmp = dp[j-b2]+a2
  if j-b3 >= 0:
    if dp[j-b3]+a3 > tmp:
      tmp = dp[j-b3]+a3
  dp[j] = tmp
print(dp[-1])

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

using namespace std;
struct edge
{
	int from;
	int to;
	int cost;
};
int d[11][11];
static const int INF = 99999999;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < 10; ++i)
		{
			for(int j = 0; j < 10; ++j)
			{
				d[i][j] = INF;
			}
			d[i][i] = 0;
		}
		for(int i = 0; i < n; ++i)
		{
			int from, to, dist;
			cin >> from >> to >> dist;
			d[from][to] = dist;
			d[to][from] = dist;
		}

		for(int k = 0; k < 10; ++k)
		{
			for(int i = 0; i < 10; ++i)
			{
				for(int j = 0; j < 10; ++j)
				{
					d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				}
			}
		}

		int min_sum_dist = INF;
		int pos = 0;
		for(int i = 0; i < 10; ++i)
		{
			int sum = 0;
			for(int j = 0; j < 10; ++j)
			{
				if(d[i][j] != INF)
				{
					sum += d[i][j];
				}
			}
			if(sum == 0)
			{
				continue;
			}
			if(min_sum_dist > sum)
			{
				min_sum_dist = sum;
				pos = i;
			}
		}
		cout << pos << " " << min_sum_dist << endl;
	}
}

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

Measured memory_bytes: 1160
N,M = map(int,input().split())
k = []
s = []
for i in range(M):
    l = list(map(int,input().split()))
    k.append(l[0])
    s.append(l[1:])
p = list(map(int,input().split()))
ans = 0
for n in range(2**N):
    n = bin(n)[2:]
    n = '0'*(N-len(n))+n
    f = True
    for i in range(M):
        sum = 0
        for j in range(k[i]):
            if n[-s[i][j]] == '1':
                sum += 1
        if sum%2 != p[i]:
            f = False
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 42864
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"

ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}

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

ll ans(ll i,ll j,ll k){
	return i*i+j*j+k*k+i*j+i*k+j*k;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ll n;
  	cin>>n;
	vl dp(10004,0);
	for(ll i=1;i<=100;i++){
		for(ll j=1;j<=100;j++){
			for(ll k=1;k<=100;k++){
				if(ans(i,j,k)>10000)
					continue;
				dp[ans(i,j,k)]++;
			}
		}
	}
	for(ll i=1;i<=n;i++)
		cout<<dp[i]<<"\n";
}

Measured memory_bytes: 3692
#include <iostream>
#include<vector>
#define ll long long

using namespace std;

ll mx=1, my = 1;
ll indX = 0;
ll indY = 0;
void mapper(int x, int y)
{
		indX += x * mx;
		indY += y * my;

		cout << indX << " " << indY <<endl;
}
int main () {
	ll x,y,k;
	cin >> k >> x >> y;
	if(k%2 == 0 && (x+y)%2==1){
		cout <<-1<<endl; return 0;
	}
	if(x < 0) {
		mx = -1;
		x *= -1;
	}
	if(y < 0) {
		my = -1;
		y *= -1;
	}
	// cout << mx << " - x " << my << " - y"<<endl;
	ll n;
	n = (x+y+k-1)/k;
	if(n==1 && x+y != k) n++;

	int iteratorcount = 0;
	while ((n*k+x+y)%2 != 0) {
		n++;	
		if(iteratorcount > 200) break;
		iteratorcount++;
	}
	if(iteratorcount > 100) {
		cout <<-1<<endl;return 0;
	}

	cout << n <<endl;
	// cout << "n - "<<n<<endl;
	ll a,b;
	b = (n*k-x-y)/2;
	a = (n*k+x+y)/2;
	// cout <<"b: "<<b<<endl;
	while(b != 0){
		// cout << x << " - x  "<< y << "  - y"<<endl; 
		if(x>y) {
			if(b > k){
				mapper(0,k*(-1));
				y -= k*(-1);
				b -= k;
			}
			else if(b != 0){
				mapper(k-b,b*(-1));
				x -= k-b;
				y -= b*(-1);	
				b = 0;
			}
		}
		else {
			if(b > k){
				mapper(k*(-1),0);
				x -= k*(-1);
				b -= k;					
			}
			else if(b != 0){
				mapper(b*(-1),k-b);
				y -= k-b;
				x -= b*(-1);	
				b = 0;
			}
		}	
	}

	// cout << x << " " << y << " last res"<<endl;	
	

	if(x >= k){
		for (ll i = 0; i < x/k; ++i)
			mapper(k,0);
		x = x%k;
	}
	if(x != 0){
		mapper(x,k-x);
		x =0;
	}

	if(y >= k){
		for (ll i = 0; i < y/k; ++i)
			mapper(0,k);
		y = y%k;
	}

	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=a*b;
        int d=2*a+2*b;
	System.out.println(c +" "+ d);
       
    }
}



Measured memory_bytes: 26212
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define cina(s, n, a) for(int i = s; i < n; i++) cin >> a[i]
#define couta(n, a) for(int i = 0; i < n; i++) cout << a[i] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "Yes" : "No")
#define mod(a, b) (b + (a % b)) % b
#define MOD  (int)1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;
typedef std::vector<pii> vpii;
using namespace std;

 
void solve(){
    int n, m;
    cin >> n >> m;
    yesno(m >= n);
}
 
int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for(int i = 1; i <= q; i++){
        solve();
    }
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2> inline bool chmin(T1 &a, const T2 &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T1, typename T2> inline bool chmax(T1 &a, const T2 &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

signed main() {
    ll A, P;
    cin >> A >> P;
    ll kake = P;
    kake += A * 3;
    cout << kake / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll MOD=1e9+7;
const ll N=2e5+5;
const ld pi=3.14159265359;
const ll INF=(1LL<<63);
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(a) (ll)a.size()

ll m1,d1,m2,d2,x;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>x;
	REP(i,N){
		if((ll)(i*1.08)==x){
			cout<<i<<"\n";return 0;
		}
	}
	cout<<":(\n";
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#include <math.h>
#include <string>
#include <vector>

long int N;
vector<int> ans;
int main(){
    cin >> N;
    while(true){
        int amari = N % (-2);
        N = N / (-2);
        if (amari == -1){
            amari += 2;
            N += 1;
        }
        ans.push_back(amari);
        if (N == 0){
            break;
        }
    }
    for (int i = ans.size() - 1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    N, M = map(int, input().split())
    ans = -1
    for n in range(M)[N:]:
        for i in range(M + 1)[n + 1:]:
            mod = n * i % 2019
            if ans < 0 or mod < ans:
                ans = mod
                if ans == 0:
                    break
        if ans == 0:
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
s = int(input())
a = [None]*2000000
r = [False]*2000000

def f(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1
a[1] = s
r[s] = True
for i in range(2, 2000000):
  a[i] = f(a[i-1])
  #print(i, a[i])
  if r[a[i]]:
    print(i)
    sys.exit()
  r[a[i]] = True
    

Measured memory_bytes: 34292
from collections import deque
m = [[1, 0], [-1, 0], [0, 1], [0, -1]]
h, w = map(int, input().split())
l = []
l.append("#"*(w + 2))

for i in range(h):
    j = input()
    l.append("#" + j + "#")

l.append("#"*(w + 2))

def bfs(a, b):
    s = [[-1 for j in i] for i in l]
    s[a][b] = 0
    q = deque([[a, b]])
    while len(q) > 0:
        x, y = q.popleft()
        for i, j in m:
            if l[x + i][y + j] == "." and s[x + i][y + j] == -1:
                q.append([x + i, y + j])
                s[x + i][y + j] = s[x][y] + 1
                num = s[x + i][y + j]
    return num

ans = []

for i in range(h + 2):
    for j in range(w + 2):
        if l[i][j] == ".":
            ans.append(bfs(i, j))

print(max(ans))

Measured memory_bytes: 9472
x, a, b = gets.chomp.split(" ").map(&:to_i)

a2 = 0
b2 = 0
if x > a
  a2 = x - a
else
  a2 = a -x
end

if x > b
  b2 = x - b
else
  b2 = b -x
end

puts a2 > b2 ? "B" : "A"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
int a=10,aa[10],b=0;
signed main()
{
	rep(i,5){
		cin>>aa[i];
		if(a>(aa[i]%10)&&aa[i]%10!=0){
			a=(aa[i]%10);
		}
	}
	rep(i,5){
		b+=(((aa[i]-1)/10)+1)*10;
	}
	cout<<b+a-10;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int K;
    string s;
    cin >> K >> s;
    if (s.size() > K)
    {
        cout << s.substr(0, K) + "..." << endl;
    }
    else
    {
        cout << s << endl;
    }
}

Measured memory_bytes: 3636
from itertools import groupby

N=int(input())
P=[]
for i in range(0,N):
    P.append(int(input()))

dic={i:0 for i in range(1,N+1)}
data=['No' for i in range(0,N)]
for i in range(0,N):
    test=P[i]
    if test!=N:
        if dic[test+1]==0:
            data[test-1]='Yes'
    dic[test]+=1

data=groupby(data)
ans=0
for key,group in data:
    g=len(list(group))
    if key=='Yes':
        ans=max(ans,g)

print(N-ans-1)

Measured memory_bytes: 89168
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cctype>
#include <cstdio>
#include <math.h>
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
const int AMAX = 100000; 
using namespace std;
#define rep(i, n) for (i64 i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
using LL = long long;
using ULL = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    int a , b, c;
    string A, B, C;
    cin >> a>>b;
if(a>=(2*b)){
cout << a-2*b;
}else{
    cout << 0;
}
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  int cnt = 0;
  bool ok = true;
  for(int i=0;i<n;i++)
    {
      char c;
      int a;
      cin >> c >> a;
      if(c == '(')
	cnt += a;
      else 
	cnt -= a;
      if(cnt < 0)
	ok = false;
    }
  if(cnt)
    ok = false;
  ok?cout <<"YES" << endl:cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <utility>
static const int MAXN = 1004;
static const double INF = 1e21;

int xs, ys, xt, yt;
int n, x[MAXN], y[MAXN], r[MAXN];

double d[MAXN][MAXN];

template <typename T> inline T sqr(const int x) { return (T)x * x; }

double dijkstra(int src, int dst)
{
    typedef std::pair<double, int> vert_info;
    std::priority_queue<vert_info, std::vector<vert_info>, std::greater<vert_info>> q;

    double dist[MAXN];
    for (int i = 0; i < n; ++i) dist[i] = INF;
    dist[src] = 0; q.push({ 0, src });

    while (!q.empty()) {
        vert_info u;
        do { u = q.top(); q.pop(); } while (dist[u.second] != u.first && !q.empty());
        if (dist[u.second] != u.first) break;
        for (int v = 0; v < n; ++v)
            if (dist[v] > u.first + d[u.second][v]) {
                dist[v] = u.first + d[u.second][v];
                q.push({ dist[v], v });
            }
    }
    return dist[dst];
}

int main()
{
    scanf("%d%d%d%d", &xs, &ys, &xt, &yt);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d%d%d", &x[i], &y[i], &r[i]);
    n += 2;
    x[n - 2] = xs, y[n - 2] = ys;
    x[n - 1] = xt, y[n - 1] = yt;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            d[i][j] = std::max(0., sqrt(sqr<double>(x[i] - x[j]) + sqr<double>(y[i] - y[j])) - (r[i] + r[j]));

    printf("%.12lf\n", dijkstra(n - 2, n - 1));
    return 0;
}


Measured memory_bytes: 14064
import java.io.*;

public class Main
{
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder str = new StringBuilder();
		str.append(br.readLine());
		int q = Integer.parseInt(br.readLine());
		String[] command = new String[4];
		String buf;
		int opr1, opr2;
		for(int i=0; i<q; i++)
		{
			command = br.readLine().split(" ");
			opr1 = Integer.parseInt(command[1]);
			opr2 = Integer.parseInt(command[2]);
			switch(command[0])
			{
			case "print":
			{
				System.out.println(str.substring(opr1, opr2+1));
				break;
			}
			case "reverse":
			{
				buf = new StringBuilder(str.substring(opr1, opr2+1)).reverse().toString();
				str.replace(opr1, opr2+1, buf);
				break;
			}
			case "replace":
			{
				str.replace(opr1, opr2+1, command[3]);
				break;
			}
			
			}
		}
	}
}


Measured memory_bytes: 24748
/**************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

***************************/

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{   ll m,n,cnt=0,j=0,l=0,y=0,t,k,sum,x=0,i,mask,min,r=0,adv,g,a,b,h;
    string s,s2;
    map<char,long long int>mp;
    char c,d;
    cin>>a>>b>>h;
    cout<<(0.5*(b-a)*h+(a*h));
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a, b, ans1, ans2, ans3;
    cin >> a >> b;
    ans1 = a + b;
    ans2 = a - b;
    ans3 = a * b;
    cout << max({ans1, ans2, ans3});
}

Measured memory_bytes: 3140
def main():
    T1, T2 = map(int, input().split())
    A1, A2 = map(int, input().split())
    B1, B2 = map(int, input().split())
    dis1_a = A1 * T1
    dis1_b = B1 * T1
    dis2_a = A2 * T2
    dis2_b = B2 * T2

    if dis1_a + dis2_a == dis1_b + dis2_b:
        print('infinity')
        exit()

    if (dis1_a - dis1_b) > 0 and (dis2_a + dis1_a - dis2_b - dis1_b) > 0:
        print(0)
        exit()

    if (dis1_a - dis1_b) < 0 and (dis2_a + dis1_a - dis2_b - dis1_b) < 0:
        print(0)
        exit()

    #print(dis1_a - dis1_b)
    #print(dis2_a + dis1_a - dis2_b - dis1_b)
    #print(dis2_a + dis1_a - dis2_b - dis1_b + (dis1_a - dis1_b))
    #print(2*(dis2_a + dis1_a - dis2_b - dis1_b))

    diff = (dis1_a - dis1_b) - (dis2_a + dis1_a - dis2_b - dis1_b + (dis1_a - dis1_b))
    cnt = (dis1_a - dis1_b) // diff
    print(cnt * 2 if (dis1_a - dis1_b) % diff == 0 else cnt * 2 + 1)

    


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<stdio.h>

int main(void)
{
	double a, b, c, d, e, f;
	double x, y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		y = (double)((c * d) - (f * a)) / (double)((b * d) - (e * a));
		x = (double)(c - (b * y)) / a;
		if(x == -0)x = 0;
		if(y == -0)y = 0;
		printf("%.3f %.3f\n", x, y);
	}
	
	return 0;
}	

Measured memory_bytes: 648
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val restriction: List<Int> = scn.nextLine().split(" ").map { it -> it.toInt() }

    data class DataPoint(val cost: Int, val time: Int)

    val dataPoints: MutableList<DataPoint> = arrayListOf()
    for (i in 0..(restriction[0] - 1)) {
        val line: List<Int> = scn.nextLine().split(" ").map { it -> it.toInt() }

        dataPoints.add(DataPoint(line[0], line[1]))
    }
    val filteredCost = dataPoints.asSequence().filter {
        it.time <= restriction[1]
    }.map {
        it.cost
    }.toList()
    if (filteredCost.isEmpty()) {
        println("TLE")
    } else {
        println(filteredCost.min())
    }

}

Measured memory_bytes: 36148
#include<iostream>
#include<sstream>
#include<algorithm>
using namespace std;
bool f(string a, string b, string c, int x){
  int crr=0;
  for(int i=0;i<(int)c.length();i++){
    int n,m, l;
    n=(i>=(int)a.length())?0
      :(a[i]=='X')?x:a[i]-'0';
    m=(i>=(int)b.length())?0
      :(b[i]=='X')?x:b[i]-'0';
    l=(i>=(int)c.length())?0
      :(c[i]=='X')?x:c[i]-'0';
    if((n+m+crr)%10!=l)return false;
    crr=(n+m+crr)/10;
  }
  return true;
}
int main(){
  string str;
  while(cin>>str){
    if(str=="END")break;
    string a,b,c;
    int flg=0;
    for(int i=0;i<(int)str.length();i++){
      if(str[i]=='+'){
        a = str.substr(0,i);
        reverse(a.begin(),a.end());
      }else if(str[i]=='='){
        b=str.substr(a.length()+1, i-a.length()-1);
        c=str.substr(i+1, str.length()-i);
        reverse(b.begin(),b.end());
        reverse(c.begin(),c.end());
      } 
    }
    if(!((a.length()!=1&&(*(a.end()-1)=='X'))
        ||(b.length()!=1&&(*(b.end()-1)=='X'))
         ||(c.length()!=1&&(*(c.end()-1)=='X')))) {
      if(f(a,b,c,0)){
        cout<<0<<endl;flg=1;
      }
    }
    for(int i=1;i<=9&&!flg;i++){
      if(f(a,b,c,i)){
        cout<<i<<endl;flg=1;
      }
    }
    if(!flg)cout<<"NA"<<endl;
  }
  return 0;
}

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

int main(){
        int N;
        cin>>N;
        vector<int> H(20);
        for(int i;i<N;i++){
                cin>>H.at(i);
}

        int answer=0;
        bool flag=true;

        for(int i=0;i<N;i++){
          flag=true;
                for(int j=0;j<i;j++){
                        if(H.at(j)<=H.at(i)){
                                continue;
                        }else{
                                flag=false;
                        }
                }
  if(flag){
                        answer++;
                }
        }
        cout<<answer<<endl;
        return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	s := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}
	//c := 0
	m := make(map[string]int)
	for i := 0; i < n; i++ {
		str := strings.Split(s[i], "")
		sort.Strings(str)
		m[strings.Join(str, "")]++
	}
	c := 0
	for _, val := range m {
		c += (val * (val - 1)) / 2
	}
	fmt.Println(c)
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	lli ans = INF;
	for(lli i=1;i*i<=n;i++){
		if(n%i==0){
			ans = min(ans,i+n/i);
		}
	}
	cout<<ans-2<<endl;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pii pair<int ,int > 
#define pb push_back
#define mo 1000000007
 int a[100005];
int main()
{
	ios ; 
int n , m ; cin>>n>>m ; 
int l , r; 
for(int i= 0; i<m ; i++)
{
	cin>>l>>r; 
	a[l]++; 
	a[r+1]--;
}

int cur = 0; 
int ans= 0; 
for(int i = 1; i<=n ; i++)
{
	cur = cur+a[i]; 
	if(cur==m)
	ans++; 
}
cout<<ans; 
	return(0);
	
}

Measured memory_bytes: 640
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();         
		int b = 1;         
		while (a != 0){System.out.println("Case "+b+": "+a);             
		b++;
		a = sc.nextInt(); 
		}
	}
}

Measured memory_bytes: 33008
#include <bits/stdc++.h>
using namespace std;
signed main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    
    if(s.size() > n){
        for(int i=0 ;i<n ;i++ ){
            cout << s[i];
        }
        cout << "...\n";
    } else {
        cout << s << endl;
    }
    return(0);
}

Measured memory_bytes: 3628