akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

//int t, n, k;
//int x[1000100];
//
//bool C(int d){
//	int co = 0;
//
//	REP(i, n){
//		if (co >= k)return false;
//		int pos = i;
//		while (x[pos] - x[i] <= d){
//			pos++;
//			if (pos == n)break;
//		}
//		i = pos - 1;
//		co++;
//	}
//
//	return true;
//}
//
//int main(){
//	cin >> t;
//	REP(o, t){
//		cin >> n >> k;
//		REP(i, n)cin >> x[i];
//
//		int lb = 0, ub = 1000000;
//		while (ub - lb > 0){
//			int mid = (ub + lb) / 2;
//			if (C(mid))ub = mid;
//			else lb = mid + 1;
//		}
//
//		vector<ll> v;
//		int pos = 0, co = 0;
//		REP(i, n){
//			if (x[i] - x[pos] > ub){
//				v.push_back(x[i - 1] - x[pos]);
//				pos = i;
//				co++;
//			}
//			if (i == n - 1){
//				v.push_back(x[i] - x[pos]);
//				co++;
//			}
//		}
//
//		sort(ALL(v));
//		REP(i, k - co){
//			if (!v.empty())v.pop_back();
//		}
//
//		ll ans = 0;
//		REP(i, v.size())ans += v[i];
//		cout << ans << endl;
//	}
//}


ll t, n, k;
ll x[1000100];

int main(){
	cin >> t;
	REP(i, t){
		cin >> n >> k;
		REP(i, n)cin >> x[i];
		V v;
		FOR(i, 1, n){
			v.push_back(x[i] - x[i - 1]);
		}
		sort(ALL(v));
		ll ans = 0;
		REP(i, n - k)ans += v[i];
		cout << ans << endl;
	}
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
ll f(ll x){
    ll ans = 1;
    fore(i, 1, x + 1)
        ans = (ans % mod * i % mod) % mod;
    return ans;
}
int main(){
  //  freopen("in","r",stdin);
    //freopen("out","w",stdout);
    fin;
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if(n == m){
        ans = f(n);
        ans = (ans % mod * ans % mod * 2) % mod;
    }else{
        if(n < m)
            swap(n, m);
        if(n - m > 1)
            ans = 0;
        else
            ans = (f(n) * f(m)) % mod;
    }
    cout << ans << '\n';
    return 0;
}   

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

int main(){
    i64 n;
    string s;
    cin>>n>>s;
    for(i64 i=0;i<s.size();i++){
        s[i] = (s[i]+n-'A')%26+'A';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const string MIN = "(^ ω ^)";

int N, M;
int A[10];
int B[10] = {0,2,5,5,4,5,6,3,7,6};
string dp[10101]; // dp[i] := maximum num of using i matches

void chmax(string &a, string b) {
    if(a == MIN) a = b;

    if(a.size() < b.size()) a = b;
    else if(a.size() == b.size()) {
        if(a < b) a = b;
    }
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> M;
    for(int i=0;i<M;++i) cin >> A[i];

    for(int i=0;i<10101;++i) dp[i] = MIN;
    dp[0] = "";

    for(int i = 0;i < N;i++){
        if(dp[i] == MIN) continue;
        for(int a : A) chmax( dp[i + B[a]], dp[i] + (char)(a + '0') );
    }
    cout << dp[N] << '\n';
    return 0;
}

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

int a, b, c;
int k;

int main()
{
	scanf("%d %d %d", &a, &b, &c);
	scanf("%d", &k);
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	while (k--)
		c *= 2;
	printf("%d\n", a + b + c);
	return 0;
}

Measured memory_bytes: 256
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();
		
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else {
			System.out.println("a == b");
		}
		sc.close();
	}

}


Measured memory_bytes: 26244
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] colors = new String[2];
        int[] nums = new int[2];
        for (int i = 0; i < 2; i++) {
            colors[i] = sc.next();
        }
        for (int i = 0; i < 2; i++) {
            nums[i] = sc.nextInt();
        }
        String color = sc.next();
        for (int i = 0; i < 2; i++) {
            if (colors[i].equals(color)) {
                nums[i]--;
                break;
            }
        }
        System.out.println(nums[0] + " " + nums[1]);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>

int main(void) {
	int H, W, h, w, all_squair, answer;
	scanf("%d %d", &H, &W);
	scanf("%d %d", &h, &w);
	all_squair = H * W;
	answer = all_squair - h * W;
	answer -= w * (H - h);
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 128
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var NM = Console.ReadLine().SplittedStringToInt32List();
        var N = NM[0];
        var M = NM[1];
        var an = new List<KeyValuePair<int, int>>();
        var dp = new int[N+1,10010];
        for (int i = 0; i < N; i++)
        {
            var vw = Console.ReadLine().SplittedStringToInt32List();
            an.Add(new KeyValuePair<int, int>( vw[0], vw[1]));
        }
        for (int i = 0; i < N+1; i++)
        {
            for (int j = 0; j < 10010; j++)
            {
                dp[i, j] = INF;
            }
        }
        dp[0, 0] = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < 10010; j++)
            {
                if (j - an[i].Key >= 0)
                    dp[i + 1, j] = Math.Min(dp[i, j], dp[i, j - an[i].Key] + an[i].Value);
                else
                    dp[i + 1, j] = dp[i, j];
            }
        }
        var max = -1;
        for (int i = 0; i < 10010; i++)
        {
            var num = dp[N, i];
            if (num <= M)
                max = i;
        }
        Console.WriteLine(max);

        Console.ReadLine();
    }
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;
    #endregion
}



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

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

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

int
main(int argc, char** argv) {
    int n ,v;

    v = 1;
    std::cin >> n;
    std::vector<int> a(n);
    int tmp;
    for (int i = 0; i < n; i++) {
        std::cin >> tmp;
        a[i] = tmp;
        v = lcm(v, a[i]);

    }
    tmp = 0;
    for (int i = 0; i < n; i++) {
        tmp += (v / a[i]);
    }
    std::printf("%lf\n", ((double)v)/tmp);
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto xy = new long[][](N);
	foreach (i; 0..N)
	{
		xy[i] = [RD, RD];
	}
	
	double ans = 0.0;
	foreach (i; 0..N)
	{
		double tmp = 0.0;
		foreach (j; 0..N)
		{
			if (i == j) continue;
			tmp += sqrt(cast(double)(xy[i][0] - xy[j][0])^^2 + cast(double)(xy[i][1] - xy[j][1])^^2);
 		}
		tmp *= N-1;
		tmp /= N;
		ans += tmp;
	}

	writefln(FMT_F, ans/(N-1));
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF =1e9+7;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    int main(void){
        fastio;
        ll n;
        c(n);
        double num = 1.08;
        ll ans;
        f(i,0,50005){
            double ii = i;
            ans = ii * num;
            if(ans == n){
                pl(i);
                return 0;
            }
        }
        pl(":(");
    }


Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	aa := &IntHeap{}
	heap.Init(aa)
	for i := 0; i < n; i++ {
		heap.Push(aa, getNextInt(scanner))
	}

	for i := 0; i < m; i++ {
		a := heap.Pop(aa).(int)
		heap.Push(aa, a>>1)
	}

	var ans int64
	for i := 0; i < n; i++ {
		ans += int64(heap.Pop(aa).(int))
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] > h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

int main()
{
  ll a,b;
  cin>>a>>b;

  cout<<a*b/gcd(a,b)<<endl;

  return 0;
}

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

int main(){
	long long n, m, ans;
	cin >> n >> m;
	
	if(n==1||m==1){
		cout << "1";
	}
	else if(n*m%2==0){
		ans=n*m/2;
		cout << ans;
	}
	else{
		ans=n*m/2+1;
		cout << ans;
	}
	
	return 0;
} 

Measured memory_bytes: 256
# C - Many Requirements
from itertools import combinations_with_replacement


def main():
    N, M, Q, *ABCD = map(int, open(0).read().split())
    conditions = tuple(zip(*[iter(ABCD)] * 4))
    ans = max(
        sum(d for a, b, c, d in conditions if comb[b - 1] - comb[a - 1] == c)
        for comb in combinations_with_replacement(range(1, M + 1), N)
    )
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
#include <stdio.h>

int main(){
    int H,W,i,j;
    while(1){
        scanf("%d %d",&H,&W);
        if(H==0&&W==0){
            break;
        }
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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;
}

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//素因数分解
vector<ll> decom;

void decompositPrime(ll n)
{
    ll a = 2;
    while (n >= a * a)
    {
        if (n % a == 0)
        {
            decom.push_back(a);
            n /= a;
        }
        else
        {
            a++;
        }
    }
    decom.push_back(n);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{

    int X; cin >> X;
    if(X>=30) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
long long  n,ans;
#define inf 1000000007
using namespace std;
int main()
{
	while(cin>>n){
		ans=1;
	for(int i=1;i<=n;i++){
		ans=(ans*i)%inf;
		
	}
	cout<<ans<<endl;	 
	}

}
  

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int L, R;
    cin >> L >> R;

    int c1, c2;
    c1 = 0;
    int mmin = 100000000;
    for ( int i = L; i < R; i ++ ) {
        c2 = 0;
        for ( int j = i+1; j <= R; j ++ ) {
//            cout << i << " "<< j << endl;
            int m = ((i%2019) * (j%2019) ) % 2019;
            if ( m < mmin ) mmin = m;
            if ( ++c2 >= 2019 ) break;
        }
        if ( ++c1 >= 2019 ) break;
    }
    cout << mmin << endl;

    return 0;
}

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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 2e5 + 9, M = 4e5 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;

int mod[2019];

int main(){
    init();

    string s;   cin >> s;
    reverse(s.begin(), s.end());

    int n = s.size();

    ll x = 0, ans = 0;

    mod[0]++;
    for(ll i = 0, p = 1;i < n;i++){
        x = p * (s[i] - '0') + x;

        x %= 2019;

        ans += mod[x]++;

        p = (p * 10) % 2019;
    }

    cout << ans;
}

Measured memory_bytes: 3708
import sys
for s in sys.stdin.readlines():
    L=[]
    for d in s.strip().split():
        if d=="-":
            d=(-(L.pop()-L.pop()))
        elif d=="+":
            d=(L.pop()+L.pop())
        elif d=="*":
            d=(L.pop()*L.pop())
        elif d=="/":
            d=(1/L.pop()*L.pop())
        L.append(float(d))
    print "%.6f"%L[0]

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

#define ll long long int

ll solve(int i,vector<ll> v,int n,vector<ll> &dp)
{
    if(i==n-1) return 0;

    if(dp[i]!=-1) return dp[i];
    ll cur = LONG_MAX;
    if(i+1 < n)
    {
        cur = min(cur,abs(v[i]-v[i+1]) + solve(i+1,v,n,dp));
    }

    if(i+2 < n)
    {
        cur = min(cur,abs(v[i]-v[i+2]) + solve(i+2,v,n,dp));
    }
    dp[i] = cur;
    return cur;
}

ll bottomUp(vector<ll> v,int k)
{
    int n = v.size();
    vector<ll> dp(n);

    dp[n-1] = 0;
    for(int i = n-2;i >=0;i--)
    {
        ll cur = LONG_MAX;
        for(int jump = 1;jump<=k && i+jump < n;jump++)
        {
            cur = min(cur, abs(v[i]-v[i+jump]) + dp[i+jump]);
        }
        dp[i] = cur;
    }

    return dp[0];
}

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

    vector<ll> v(n);
    for(int i = 0;i<n;i++) cin>>v[i];

    // vector<ll> dp(n,-1);
    // cout<<solve(0,v,n,dp);
    cout<<bottomUp(v,k);
}


Measured memory_bytes: 2560
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
diff=1000000
for i in range(n):
    ave=t-(h[i]*0.006)
    tmp=a-ave
    if tmp < 0:
        tmp*=-1
    if diff > tmp:
        diff=tmp
        ans=i+1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define MP make_pair
#define PB push_back
#define in int
#define ll long long
#define ull unsigned long long
#define vc vector
#define SQ(j) (j)*(j)
#define x first
#define y second
//
//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pdd pair<dbl,dbl>
#define sz(xxx) ((int)(xxx.size()))
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

//#define printf(...) (0)
#define db(x) if(DEBUG) {cout << #x << " = " << x << endl;}
#define dbCont(x) if(DEBUG) {cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout<<endl;}

using namespace std;

template<class K, class V>
ostream &operator<<(ostream &out, pair<K, V> &elem) {
    out << "{" << elem.first << "," << elem.second << "}";
    return out;
}

// 4:13

int DEBUG = 0;

using namespace std;

const int N = 100 * 1000 + 5;
const ll MOD = 1000 * 1000 * 1000 + 7;

int main() {

    ll n, k;
    cin >> n >> k;

    ll sum = 0;
    multiset<ll> st;
    loop(i,n){
        ll e;
        cin >> e;
        st.insert(e);
    }

    while(st.size() && k) {
        k--;
        st.erase(--st.end());
    }

    ll s = 0;
    for(auto e : st) s += e;

    cout << s << endl;


    return 0;
}


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

int ans = 1e9;
int n,m,x;
vector<int> c;
vector<vector<int>> a;
vector<int> f;

void dfs(int itr, int flag) {
  if(flag) f[itr] = 1;
  else f[itr] = 0;

  if(itr == n - 1) {
    int sum = 0;
    vector<int> tmp(m, 0);
    for (int i = 0; i < n; i++) { //本を選ぶかどうか
      if(f[i] == 0) continue;
      sum += c[i];
      for (int j = 0; j < m; j++) {
        tmp[j] += a[i][j];
      }
    }
    bool ok = true;
    for (int i = 0; i < m; i++) {
      if(tmp[i] < x) ok = false;
    }
    if(ok) ans = min(ans, sum);
    return;
  }
  dfs(itr + 1, 1);
  dfs(itr + 1, 0);

  return;
}

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

  cin >> n >> m >> x;
  f.resize(n);
  c.resize(n);
  a.resize(n, vector<int> (m));

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

  dfs(0, 0);
  dfs(0, 1);

  if(ans == 1e9) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll m,d; cin>>m>>d;

    ll ans = 0;

    FOR(i,1,d){
        ll x = i%10,y = i/10;
        ll val = x*y;
        if(x >= 2 && y >= 2 && val >= 1 && val <= m) ans++;
    }

    cout<<ans<<endl;
} 
 
signed main(){
 
   FastRead;    
 
 
    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
    vector<int> v;
    while (true) {
        int a, b;
        char op;
        cin >> a >> op >> b;

        if (op == '?') break;
        
        int ans;
        switch (op) {
            case '+':
                ans = a + b;
                break;
            case '-':
                ans = a - b;
                break;
            case '*':
                ans = a * b;
                break;
            case '/':
                ans = a / b;
                break;
            default:
                continue;
        }
        v.push_back(ans);
    }
    for (auto ans : v) {
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;

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

	vector<vector<int>> g(n);
	vector<P> ps;

	rep(i, n - 1)
	{
		int a, b;
		cin >> a >> b;

		a--;
		b--;

		g[a].emplace_back(b);
		g[b].emplace_back(a);

		ps.emplace_back(a, b);
	}

	//解答格納用の変数
	//使用する色の個数
	int k = 0;

	//辺の色
	map<P, int> colors;

	//各頂点につながっている色の最大値
	//木を対象とするため、１頂点に対して１色を管理すれば十分
	vector<int> minc(n, 0);


	//幅優先探索
	queue<int> q;
	vector<bool> used(n, false);

	q.emplace(0);
	used[0] = true;

	while (!q.empty())
	{
		int v = q.front(); q.pop();

		//色の最大値は頂点の次数の最大値
		k = max(k, (int)g[v].size());

		//現在の頂点から出る辺を色塗り
		int c = 1;

		for (auto u : g[v])
		{
			//探索済みの場合は無視
			if (used[u])continue;

			//使用済みならスキップ
			if (c == minc[v]) c++;

			//色の更新後カウントアップ
			minc[u] = colors[make_pair(u, v)] = colors[make_pair(v, u)] = c++;

			used[u] = true;

			q.emplace(u);
		}
	}

	cout << k << endl;
	for (auto p : ps)
	{
		cout << colors[p] << endl;
	}

	return 0;
}

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

int main() {
    int N;
    cin>>N;
    N%=10;
    if(N==3){
        cout<<"bon"<<endl;
    }else if(N==0||N==1||N==6||N==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}

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


ll c(vector<ll> a) {
  ll sum = 0;
  ll r = a[0];
  ll len = (ll) a.size();
  for(int i = 1;i<len;i++) {
    //cout << "r " << r << " sum -> " << sum << endl;
    if(r > a[i]) {
      sum += r - a[i];
      //cout << " up " << r - a[i] << endl;
    } else {
      r = a[i];
     // cout << "ok" << endl; 
    }
  }

  return sum;
}

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

Measured memory_bytes: 6404
import sys

input = sys.stdin.readline


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

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13876
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a>b) cout << "a > b" << endl;
    else if(a<b) cout << "a < b" << endl;
    else cout << "a == b" << endl;
}


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

using namespace std;

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int n, x = 0;

    cin >> n;

    int v[n], c[n], ans[n];

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

        cin >> c[i];
        ans[i] = v[i]-c[i];
    }

    sort(ans, ans+n);

    for (int i = n-1; i >= 0; i--) {

        if (ans[i] > 0) x+=ans[i];
        else return cout << x, 0;
    }

    cout << x;

    return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

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

int main(){
  LL n;

  scanf("%lld",&n);

  if (n % 11 != 0) printf("%lld\n",2 * (n / 11) + ((n % 11) / 7) + 1);
  else printf("%lld\n",2 * (n / 11) + ((n % 11) / 7));
}


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

int main() {
  int h, w;
  cin >> h >>w;
  vector<string> s(h);
  for (int i = 0; i < h; i++){
    cin >> s[i];
  }
  
  for (int i = 0; i < w + 2; i++){
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < h; i++){
    cout << '#' << s[i] << '#' << endl;
  }
  for (int i = 0; i < w + 2; i++){
    cout << '#';
  }
}

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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int n, q;
std::string s;
V<int> v;

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

    v.push_back(0);
    FOR(i, 1, n) {
        if(s[i-1] == 'A' && s[i] == 'C')
            v.push_back(v[i-1]+1);
        else
            v.push_back(v[i-1]);
    }

    REP(i, q) {
        int l, r;
        cin >> l; cin >> r;
        cout << v[r-1] - v[l-1] << "\n";
    }
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref : https://atcoder.jp/contests/abc086/submissions/7707107

int b[2005][2005];

int main(){
    int n, k;
    cin >> n >> k;
    
    rep(i, n){
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') y += k;
        b[y%(2*k)+1][x%(2*k)+1]++;
    }
    rep(i, 2*k) rep(j, 2*k) b[i+1][j+1] += b[i+1][j] + b[i][j+1] - b[i][j];

    int ans = 0;

    rep(i, k+1) rep(j, k+1){
        int tmp = 0;
        tmp += b[i+k][j+k] - b[i+k][j] - b[i][j+k] + b[i][j];
        tmp += b[2*k][2*k] - b[i+k][2*k] - b[2*k][j+k] + b[i+k][j+k];
        tmp += b[i][j];
        tmp += b[i][2*k] - b[i][j+k];
        tmp += b[2*k][j] - b[i+k][j];
        ans = max({ans, tmp, n - tmp});
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19312
N, M, C = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
count = 0
N.times do
  a = gets.split.map(&:to_i)

  count += 1 if a.zip(b).map{|c| c.inject(:*)}.inject(:+) + C > 0
end

puts count

Measured memory_bytes: 3836
#include <cstdio>
#include <algorithm>
bool cmp(int x,int y){return x>y;}
int n,a[200003],p;
long long ans;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    std::sort(a+1,a+1+n,cmp);
    ans=a[1],p=2;
    for(int i=3;i<=n;i++){
        ans+=a[p];
        if(!(i&1)) ++p;
    }
    printf("%lld\n",ans);
    return 0;
}

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

lst = []
for i in range(n):
    lsti = [a[i], b[i]]
    lst.append(lsti)

lst.sort(key=lambda x: x[0])
lst.sort(key=lambda x: x[1])

sorted_a = []
sorted_b = []
for i in range(n):
    sorted_a.append(lst[i][0])
    sorted_b.append(lst[i][1])

ind = list(range(n))
lst = []
for i in range(n):
    lsti = [ind[i], sorted_a[i]]
    lst.append(lsti)
lst.sort(key=lambda x: x[1])

sorted_ind = []
shoujun_a = []
for i in range(n):
    sorted_ind.append(lst[i][0])
    shoujun_a.append(lst[i][1])

for i in range(n):
    if sorted_b[i] < shoujun_a[i]:
        print('No')
        exit()

lenghth = 1
start = 0
i = 0
while start != sorted_ind[i]:
    lenghth += 1
    i = sorted_ind[i]

if lenghth != n:
    print('Yes')
else:
    for i in range(n-1):
        if sorted_b[i] >= shoujun_a[i+1]:
            print('Yes')
            exit()
    print('No')

Measured memory_bytes: 29940
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int a, b, c;

bool read() {
  if (scanf("%d%d%d", &a, &b, &c) < 3) {
    return false;
  }
  return true;
}

void solve() {
  int res = b + min(a + b + 1, c);
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a,b;
	char op;
	do{
		scanf("%d %c %d",&a,&op,&b);
		if(op == '?') break;
	switch(op){
	case '+' :{
		printf("%d\n",a+b);
		break;
			  }
	case '-' :{
		printf("%d\n",a-b);
		break;
			  }
	case '*' :{
		printf("%d\n",a*b);
		break;}
	case '/' :{
		printf("%d\n",a/b);
		break;
			  }
	}
	}while(1);
	return 0;
}

Measured memory_bytes: 600
fun main() = Thread(null, ::abc174a, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc174a() {
    val x = readLine()!!.toInt()

    val answer = if (x >= 30) "Yes" else "No"

    println(answer)
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  int ans = 0;
  for(int i = 1; i <= n; ++i) {
    string s = to_string(i);
    int sum = 0;
    for(auto c : s) sum += (c-'0');
    if(a <= sum && sum <= b) ans += i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

satis = 0
idAprev = 0
for idA in A:  
  satis += B[idA - 1]
  if idAprev != 0 and (idA - idAprev) == 1:
    satis += C[idAprev - 1]
    
  idAprev = idA

print(satis)

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

int main()
{
    int n,temp =0;
    cin>>n;
    int ar[n+5],br[n+5];
    for(int i =0;i<n;i++){
        cin>>ar[i];
        br[i] = ar[i];
    }
    sort(ar,ar+n);
    for(int i =0;i<n;i++){
        if(ar[i] != br[i]){
            temp ++;
        }
    }
    if(temp < 3){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;

    vector<int> x(N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> x[i];
        ans += min(x[i], K - x[i]) * 2;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    char c;
    cin  >> c;
    bool flag = false;
    if(c=='a')flag = true;
    if(c=='i')flag = true;
    if(c=='u')flag = true;
    if(c=='e')flag = true;
    if(c=='o')flag = true;
    if(flag){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=1;i<=k;i++)
	{
		if(i%2==1)
		{
			if(a%2==1)
			{
				a--;
			}
			a/=2;
			b+=a;
		}
		else
		{
			if(b%2==1)
			{
				b--;
			}
			b/=2;
			a+=b;			
		}
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  string S;
  cin >> S;

  sort(S.begin(), S.end());
  cout << ((S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(1) != S.at(2)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def main(input = STDIN)
  n = input.gets.to_i
  m = n
  output = ["#{n}:"]
  while m % 2 == 0
    output << 2
    m /= 2
  end
  f = 3
  while m != 1 and f ** 2 <= n
    while m % f == 0
      output << f
      m /= f
    end
    f += 2
  end
  output << m if m != 1
  puts output.join(" ")
end
main

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string a, b;
    cin >> a >> b;
    for(int i=0; i<max(a.size(), b.size()); ++i){
        if(i < (int)a.size())
            cout << a[i];
        if(i<(int)b.size())
            cout << b[i];
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    cout << T / A * B << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    int N,M;
    cin >> N >> M;
    int G[N][N] = {};
    vector<vector<int>> E;
    rep(i,N){
        rep(j,N){
            if(i==j) G[i][j] = 0;
            else G[i][j] = 10000000;
        }
    }
    rep(i,M){
        int a,b,c;
        cin >> a >> b >> c;
        a--,b--;
        G[a][b] = c;
        G[b][a] = c;
        vector<int> e = {a,b,c};
        E.emplace_back(e);
    }

    rep(k,N){
        rep(i,N){
            rep(j,N){
                G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
            }
        }
    }

    int res = 0;
    rep(i,E.size()){
        int a = E[i][0];
        int b = E[i][1];
        int c = E[i][2];
        rep(i,N){
            if(G[i][a] + c == G[i][b]){
                res++;
                break;
            }
        }
    }
    cout << M - res << endl;

    return 0;
}

Measured memory_bytes: 384
# if assignment already exists for a digit, check it is consistent.
# no leading zeroes (except for the number zero)
# given constraints are ok, fill other digits with zeros (and potentially 1 for lead)

def assign_digits(ans):
  for _ in range(M):
    new_s = s.pop()
    new_c = c.pop()
    if flags_assigned[new_s-1] == 1:
      if new_c != int(ans[new_s-1]): return [str(-1)]
    else:
      flags_assigned[new_s-1] = 1
      ans[new_s-1]=str(new_c)
  if ans[0] == "0" and len(ans)>1: return [str(-1)]
  return ans

N, M = map(int, input().split())
s = list()
c = list()
for _ in range(M):
  row = list(map(int, input().split()))
  s.append(row[0])
  c.append(row[1])

if N==1:
  ans = [str(0)]
elif N==2:
  ans = [str(1), str(0)]
elif N==3:
  ans = [str(1), str(0), str(0)]
flags_assigned = [0]*N

print(int("".join(assign_digits(ans))))


Measured memory_bytes: 3064
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        if i % 3 == 0 or i % 5 == 0:
            continue
        else:
            ans += i

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9944