akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import itertools
import collections
import functools
import math
import operator
from queue import Queue
INF = float("inf")


def dfs(curr, goal, count, probs):
    if curr >= goal:
        return count

    if len(probs) == 0:
        return INF

    # ラス一問目を解かない
    m1 = dfs(curr, goal, count, probs[:-1])

    # ラス一問目を解ききる
    m2 = dfs(curr+probs[-1][0] * probs[-1][1] + probs[-1][2],
             goal, count+probs[-1][1], probs[:-1])

    # ラス一問目を途中まで解く
    m3 = INF
    s = goal-curr
    if (probs[-1][0] * probs[-1][1]) >= s:
        m3 = count + int(math.ceil(s / probs[-1][0]))

    # print(m1, m2, m3, curr, count, probs)
    return min(m1, m2, m3)


def solve(D: int, G: int, p: "List[int]", c: "List[int]"):

    probs = []
    for i in range(D):
        probs.append([100*(i+1), p[i], c[i]])

    m = dfs(0, G, 0, probs)
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    p = [int()] * (D)  # type: "List[int]"
    c = [int()] * (D)  # type: "List[int]"
    for i in range(D):
        p[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(D, G, p, c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4320
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    int cnt = 0;
    for (char c : s){
        if (c == 'p') cnt++;
    }
    cout << n / 2 - cnt << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    lint n; cin >> n;
    lint sum = 0; vector<lint> v(n);
    rep(i, n){
        cin >> v[i]; sum += v[i];
    }
    sum /= n;

    lint p = 0;
    rep(i, n){
        p += (lint)pow(v[i]-sum, 2);
    }
    lint q = 0;
    rep(i, n){
        q += (lint)pow(v[i]-sum-1, 2);
    }
    out(min(p,q));
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	double x;
	
	while(scanf("%lf", &x)!=EOF){
		if(x<=48.00)
		printf("light fly\n");
		if(x>48.00 && x<=51.00)
		printf("fly\n");
		if(x>51.00 && x<=54.00)
		printf("bantam\n");
		if(x>54.00 && x<=57.00)
		printf("feather\n");
		if(x>57.00 && x<=60.00)
		printf("light\n");
		if(x>60.00 && x<=64.00)
		printf("light welter\n");
		if(x>64.00 && x<=69.00)
		printf("welter\n");
		if(x>69.00 && x<=75.00)
		printf("light middle\n");
		if(x>75.00 && x<=81.00)
		printf("middle\n");
		if(x>81.00 && x<=91.00)
		printf("light heavy\n");
		if(x>91.00)
		printf("heavy\n");
		
	}
	return 0;
}

Measured memory_bytes: 604
import std.stdio;
import std.random;
import std.datetime;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int rand(int M) {
    int ret = rndGen.front % M;
    rndGen.popFront;
    return ret;
}
 
void main() {
    int N; scanf("%d\n", &N);
    auto X = new char[][](N, N);
    foreach (i; 0 .. N) {
        X[i] = cast(char[])readln.chomp.dup;
    }
    struct P {
        int c;
        string s;
    }
    auto Y = new P[N];
    foreach (int i; 0 .. N) {
        Y[i].c = i;
        Y[i].s = cast(string)(X[i]);
    }
    Y.sort!"a.s.count('x') < b.s.count('x')";
    //writeln(Y);
    int M = cast(int)(Y[0].s.count('x'));
    rndGen.seed(Clock.currTime.second);
    int ai_prev;
    //writeln("M: ", M);
    if (M == 0) {
        foreach (i; 0 .. 1000) {
            writeln(Y[0].c + 1);
            fflush(std.c.stdio.stdout);
            scanf("%d", &ai_prev);
        }
    } else {
        foreach (i; 0 .. 1000) {
            writeln(Y[rand(N)].c + 1);
            fflush(std.c.stdio.stdout);
            scanf("%d", &ai_prev);
        }
    }
}

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define mem(a,b) memset(a,b,sizeof(a))
#define shutdown ios::sync_with_stdio(false)
#define MAX 10e18+1000



int main() {
    shutdown;
    string t;
    cin>>t;
    int s=t.length();
    for(int i=0;i<s-8;i++)
        cout<<t[i];
    cout<<endl;
    return 0;
}


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

int main()
{
    int d;
    while(cin >> d){
        int allS=0;
        for(int i=0 ; i<600/d ; i++){
            allS += d*d*i*d*i;
        }
        cout << allS << endl;
    }
    return 0;
}

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

int main()
{
	int n, x, t;
	cin >> n >> x >> t;

	int num = n / x;
	if (x == 1)
	{
		cout << n*t << endl;
	}
	else
	{
		if ((n % x) != 0)
		{
			cout << (num + 1)*t << endl;
		}
		else
		{
			cout << num*t << endl;
		}
	}

}

Measured memory_bytes: 3532
open Batteries
module Mymap = Map.Make(Int)
let () =
  let n = Scanf.scanf "%d " (fun a -> a) in
  let m = Scanf.scanf "%d " (fun a -> a) in
  let pair_lst = Array.to_list @@ Array.init m (fun _ -> Scanf.scanf "%d %d " (fun a b -> a,b)) in

  let lst = List.init n (fun i -> i+1) in
  let amap = Mymap.empty in
  let amap = List.fold_left (fun map i -> Mymap.add i 0 map) amap lst in

  let amap = List.fold_left (fun accum (x,y) -> 
      Mymap.modify_opt x (fun v_opt -> match v_opt with
            Some v -> Some (v + 1)
          | None -> Some 1
        ) accum |>
      Mymap.modify_opt y (fun v_opt -> match v_opt with
            Some v -> Some (v + 1)
          | None -> Some 1
        ) 
    ) (amap) pair_lst
  in

  let pair_lst = Mymap.bindings amap in
  let pair_lst = List.sort compare pair_lst in
  List.iter (fun (x,y) -> Printf.printf "%d\n" y) pair_lst


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

public class Main{
    public static void main (String args[]){
        //初期処理
        Scanner sc=new Scanner(System.in);
        int n=Integer.parseInt(sc.nextLine());
        String[] sElementArray=sc.nextLine().split(" ");
        //int[] array=Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();
        int[] array=new int[n+1];
        for(int i=0;i<n;i++){
            array[i+1]=Integer.parseInt(sElementArray[i]);
        }
        sc.close();

        // BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //    try{
        //         int n= Integer.parseInt(br.readLine());
        //         int[] array = Arrays.stream(sElementArray).mapToInt(Integer::parseInt).toArray();
                
        //     }catch(IOException e){e.printStackTrace();}

        StringBuilder sb= new StringBuilder();
        
        for(int i=1;i<=n;i++){
            sb.append("node "+i+": ");
            sb.append("key = "+array[i]+", ");
            if(parent(i)>=1) sb.append("parent key = "+array[parent(i)]+", ");
            if(left(i)<=n) sb.append("left key = "+array[left(i)]+", ");
            if(right(i)<=n) sb.append("right key = "+array[right(i)]+", ");
            sb.append("\n");
        }
        System.out.print(sb);
    }
    
    //return index of each node
    static int parent(int h){return h/2;}
    static int left(int h){return 2*h;}
    static int right(int h){return 2*h+1;}
}
    


Measured memory_bytes: 26368
#include<stdio.h>

int main(void){
	int min,go,i,j,N,count = 0;
	int A[100];
	
	scanf("%d",&N);
	
	for(i=0;i<N;++i){
		scanf("%d",&A[i]);
	}
	
	for(i=0;i<N;++i){
		min = i;
		for(j=i+1;j<N;++j){
			if(A[j]<A[min]){
				min = j;
			}
		}
		go = A[i];
		A[i] = A[min];
		A[min] = go;
		if(A[i] != A[min])count++;
	}
	
	for(i=0;i<N;++i){
		printf("%d",A[i]);
		if(i<N-1)printf(" ");
	}
	printf("\n%d\n",count);
	return 0;
}

Measured memory_bytes: 604
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int x = sc.nextInt(), y = sc.nextInt();

		long half = c * Math.min(x, y) * 2;
		if(x > y) {
			half += a * (x-y);
		}else if(x < y) {
			half += b * (y-x);
		}

		long ahalf = c * Math.max(x, y) * 2;

		long each = a*x + b*y;

		System.out.println(Math.min(half, Math.min(ahalf, each)));
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 32824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int INF = 1000000007;

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

  int K;
  string S;
  cin >> S >> K;
  int N = S.size();
  int W;
  if(N >= 5){
    W = (N-5)*5 + 15;
  }
  else W = N*(N+1)/2;
  string T[W] = {};
  int num = 0;
  for(int i=0;i<N;i++){
    for(int j=i;j<min(i+5,N);j++){
      T[num] = S.substr(i,j-i+1);
      num++;
    }
  }
  sort(T, T+W);
  int M = 0;
  for(int i=1;i<K;i++){
    while(T[M+1] == T[M]){
      M++;
    }
    M++;
  }
  cout << T[M] << endl;
}

Measured memory_bytes: 1664
n = int(input())
s = ['.'] * n
for i in range(n):
    s[i] = str(input())

dict = {}

for i in range(n):
    if s[i] in dict:
        dict[s[i]] += 1
    else:
        dict[s[i]] = 1
        
m = max(dict.values())

keys = [k for k, v in dict.items() if v == m]
keys.sort()
for i in range(len(keys)):
    print(keys[i])


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

#define ll long long
#define F(i,m,n) for(ll i=m;i<n;i++)
#define Fr(j,n,m) for(ll j=n;j>=m;j--)
#define vll vector<ll>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpll vector< pll >
#define tlll tuple < ll ,ll,ll >
/*-------------------------------------*---------------------------------------*/

#define godspeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl
#define cout_array(a) cout<<#a<<"=";for(auto x: a){ cout<<x<<" ";}cout<<endl

ll gcd(ll a,ll b){
    return (b?gcd(b,a%b):a);
}
const ll MAX_PRIME = 1e9+7;
const ll INF = 1e18;


/*I NEED YOU TO WORK FOR TWO HOURS ON THIS NO MATTER WHAT....THE RESULT DOESN'T MATTER.....ITS ALL ABOUT YOUR EFFORTS.
---------------------------------------------------------------------------------------------------------------------*/

ll fast_pow(ll x,ll y,ll z){
    if(y==0)return 1%z;
    else if(y==1)return x%z;
    if(y%2==0){
        ll res = fast_pow(x,y/2,z);
        return (res*res)%z;
    }
    else{
        ll res = fast_pow(x,y/2,z);
        ll temp = (res*res)%z;
        return ((x%z)*temp)%z;
    }
}
int main() {
    godspeed
    ll n;
    cin>>n;
    ll val1 = (fast_pow(10,n,MAX_PRIME) - 2*fast_pow(9,n,MAX_PRIME)+fast_pow(8,n,MAX_PRIME) + 4*MAX_PRIME)%MAX_PRIME;
    cout<<val1<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s[0]=='7'||s[1]=='7'||s[2]=='7')cout <<"Yes" <<endl;
    else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <utility>
#include <cstdio>
using namespace std;

typedef pair<int,int> pii;
char t[102][102];
	//0: 囲まれていない
	//1: 建物があるか、囲まれている
	//2: 囲まれているかもしれない
int d[2][12] = {
	{ -1, -1, -1, 0, -1, 1, 0, -1, 1, 0, 0, 1 },
	{ 0, -1, -1, 0, 0, 1, 1, -1, 1, 0, 1, 1 }
};	//jに依存

int main(){
	int w, h, s;
	cin >> w >> h;
	for( int j = 1; j <= h; ++j ){
		for( int i = 1; i <= w; ++i ){
			cin >> s;
			t[i][j] = 2 - s;
		}
	}
	
	for( int i = 1; i <= w; ++i ){
		for( int j = 1; j <= h; ++j ){
		
			if( t[i][j] == 2 ){
				vector<pii> v1, v2;
				v1.push_back( pii( i, j ) );
				bool f = false;
				while( !v1.empty() ){
					pii b = v1.back();
					v1.pop_back();
					
					if( t[b.first][b.second] == 0 ){
						f = true;
					}
					else if( t[b.first][b.second] == 2 ){
						t[b.first][b.second] = 1;
						v2.push_back( b );
						for( int k = 0; k < 12; k += 2 ){
							v1.push_back( pii(
								b.first + d[b.second % 2][k],
								b.second + d[b.second % 2][k + 1]
							) );
						}
					}
				}
				
				

				
				
				if( f ){
					for( int k = 0; k < v2.size(); ++k ){
						t[ v2[k].first ][ v2[k].second ] = 0;
					}
				}
			}
		}
	}

	s = 0;
	for( int i = 1; i <= w; ++i ){
		for( int j = 1; j <= h; ++j ){
			if( t[i][j] == 1 ){
				for( int k = 0; k < 12; k += 2 ){
					if( t[i + d[j%2][k] ][j + d[j%2][k+1] ] != 1 ){
						++s;
					}
				}
			}
		}
	}
	
	cout << s << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",800*N-200*(N/15));

	return 0;
}


Measured memory_bytes: 256
n, c, k = map(int, input().split())
q = sorted([int(input()) for i in range(n)])
ans = 1
f = q.pop(0)
p = 1
for i in q:
    if i > f + k or p >= c:
        ans += 1
        f = i
        p = 1
    else:
        p += 1
print(ans)


Measured memory_bytes: 8280
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void solve();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int q=1;//cin>>q;
    while(q--){
        solve();
    }
    return 0;
}
void solve(){
ll int a,b,c,d;cin>>a>>b>>c>>d;
  cout<<max(a*c,max(a*d,max(b*c,b*d)))<<endl;
}

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

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

using namespace std;

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

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

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll n;
    cin >> n;
    ll a[n+2]; a[0] = a[n+1] = 0;
    rep(i, n) cin >> a[i+1];
    ll v  =0;
    for(ll i = 1; i <= n+1; i++) v += abs(a[i] - a[i-1]); //cout << v << " ";
    for(ll i = 1; i <= n; i++) {
        cout << v - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
    }

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
    int x,y,ans=0;
    cin >> x >> y;
    switch(x){
        case 1:
        ans+=300000;
        break;
        case 2:
        ans+=200000;
        break;
        case 3:
        ans+=100000;
        break;
    }
    switch(y){
        case 1:
        ans+=300000;
        break;
        case 2:
        ans+=200000;
        break;
        case 3:
        ans+=100000;
        break;
    }
    if(x==1 && y==1)
    ans+=400000;

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

long long a[100001],n,m,head[100001],nxt[200001],b[200001],k,fa[100001];
long long B[100001],f[100001];
bool vis[100001];
void push(int s,int t){
	nxt[++k]=head[s];
	head[s]=k;
	b[k]=t;
}
int find(int x){return f[x]?f[x]=find(f[x]):x;}
std::pair<int,int>p[100001];
void dfs(int x){
	for(int i=head[x];i;i=nxt[i])dfs(b[i]),B[x]+=B[b[i]];
	f[x]=a[x]+B[x];
	for(int i=head[x];i;i=nxt[i])f[x]=std::min(f[x],B[x]-B[b[i]]+std::max(a[x],f[b[i]]));
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d%d",a+i,B+i),a[i]=std::max(a[i]-B[i],0ll),p[i]=std::make_pair(a[i],i);
	for(int i=1,u,v;i<=m;i++)scanf("%d%d",&u,&v),push(u,v),push(v,u);
	std::sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		int u=p[i].second;
		for(int j=head[u];j;j=nxt[j])
			if(vis[b[j]]&&find(b[j])!=find(u)){
				int fu=find(b[j]);
				fa[fu]=u;
				f[fu]=u;
			}
		vis[u]=1;
	}
	memset(head,0,sizeof head);
	k=0;
	int root;
	for(int i=1;i<=n;i++)(fa[i])?push(fa[i],i),0:root=i;
	dfs(root);
	printf("%lld\n",f[root]);
}

Measured memory_bytes: 9984
import math
import itertools
import statistics
#n = int(input())
#n, d = list(input().split())
#h, w = list(map(int, input().split()))
a = []
for i in range(3):
    a.append([int(j) for j in input().split()])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i]==a[j][k]:
                a[j][k]=0



for i in range(3):
    if a[i][0]==0 and a[i][1]==0 and a[i][2]==0:
        print("Yes")
        exit()
    
    if a[0][i]==0 and a[1][i]==0 and a[2][i]==0:
        print("Yes")
        exit()

if a[0][0]==0 and a[1][1]==0 and a[2][2]==0:
    print("Yes")
    exit()
elif a[2][0]==0 and a[1][1]==0 and a[0][2]==0:
    print("Yes")
    exit()


print("No")




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

int main(void){
   long long n, a, b;
   long long ans, res;

   cin >> n >> a >> b;
   ans = a * (n / (a + b));
   res = n % (a + b);

   if (res < a){
     ans += res;
   } else {
     ans += a;
   }
   cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import queue

q = queue.Queue()

k = int(input())

for i in range(1,10):
    q.put(i)
    
while(k > 0):
    x = q.get()
    if x % 10 != 0:
        q.put(x*10 + (x%10 - 1))
    q.put(x*10 + x%10)
    if x % 10 != 9:
        q.put(x*10 + (x%10 + 1))
    k -= 1
    
print(x)

Measured memory_bytes: 13016
s=list(input())
n=len(s)
a=0
b=[]
i=0
def ac(b):
  a=b[::-1]
  t,c=0,0
  for i in range(len(b)):
    if a[i]==0:c+=i-t;t+=1
  return c
while i<n:
  f=True
  if s[i]=="A":b.append(0);f=False
  if i<n-1:
    if s[i]+s[i+1]=="BC":b.append(1);f=False;i+=1
  if f:
    a+=ac(b)
    b=[]
  i+=1
print(a+ac(b))

Measured memory_bytes: 8100
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/***********************************************************************/
i64 f(i64 x) {
  if (x == 1) return 1;
  return 2 * f(x / 2) + 1;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  i64 x; cin >> x;
  cout << f(x) << '\n';
}


Measured memory_bytes: 256
package main

import "fmt"
import "bufio"
import "os"
import "strconv"
import "sort"

var _sw = bufio.NewScanner(os.Stdin)

func main() {
	N := NextInt()
	A := NextInts(N)

	m := 0
	ans := 0
	for _, a := range A {
		m = Max(a, m)
		ans += m - a
	}
	fmt.Println(ans)
}

func init() {
	_sw.Split(bufio.ScanWords)
}

func NextInt() int {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	i, e := strconv.Atoi(_sw.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func NextInts(n int) []int {
	a := make([]int, n)
	for i := range a {
		a[i] = NextInt()
	}
	return a
}

func NextString() string {
	if _sw.Scan() == false {
		panic(_sw.Err())
	}
	return _sw.Text()
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func Bounded(lower, n, upper int) int {
	return Min(upper, Max(lower, n))
}

func SortInts(xs []int) {
	sort.Sort(sort.IntSlice(xs))
}

func ReverseSortInts(xs []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(xs)))
}


Measured memory_bytes: 5852
#include <vector>
#include <iostream>
#include <stdio.h>
#include <functional>
#include <cassert>

using namespace std;

int main() {
	int n, q, x, y, com, tmp;
	cin >> n >> q;
	vector<int> a(n+1, 0);
	for (int i = 0; i < q; ++i) {
		cin >> com >> x >> y;
		if (com == 0) {
			a[x] += y;
		}
		else {
			int ans=0;
			for (int j = x; j <= y; ++j) {
				ans += a[j];
			}
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3132
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]

if x in g1 and y in g1 or x in g2 and y in g2:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include<string>
using namespace std;
int main(void){

    int A,B,C,D;

    
    cin>>A>>B>>C>>D;
    //左//右
    if(A+B > C+D)
    {
        cout<<"Left"<<endl;
    }
    else if(A+B<C+D)
    {
        cout<<"Right"<<endl;
    }else cout<<"Balanced"<<endl;
    
    
   
    
    return 0;
}

Measured memory_bytes: 256
//
//  cookies.cpp
//  
//
//  Created by Òscar Balcells on 09/02/2019.
//

#include <iostream>

using namespace std;

int main() {
    
    long long int k, a, b;
    scanf("%lld %lld %lld", &k, &a, &b);
    
    long long int cookies = 1;
    int yen = 0;
    
    if(a+2 < b) {
        
        while(k--) {
            
            if(yen) {
                
                cookies += b;
                yen = 0;
                
            } else if(k > 0 && cookies >= a) {
                
                cookies -= a;
                yen++;
                
            } else {
                
                cookies++;
                
            }
        }
        
        
    } else {
        //lo mejor es picar bolsillo todo el rato
        cookies += k;
    }
    
    printf("%lld\n", cookies);
    
    return 0;
}


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

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

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl

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

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

int sumi(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int main(){

	int n, a, b;
	cin >> n >> a >> b;
	int sum = 0;

	for (int i = 1; i <= n; i++) {
		if (a<=sumi(i) && sumi(i) <=b) {
			sum += i;
		}
	}

	pr(sum);
	return 0;
}

Measured memory_bytes: 256
from collections import deque

def main():
    n, m = map(int, input().split())
    route = [[] for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        route[a].append(b)
        route[b].append(a)
    q = deque([1])
    ans = [None]*(n+1)
    while q:
        parent = q.pop()
        children = route[parent]
        for child in children:
            if ans[child] is None:
                ans[child] = parent
                q.appendleft(child)
    print("Yes")
    print("\n".join(list(map(str, ans[2:]))))
    

if __name__ == "__main__":
    main()

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

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

struct P {
  bool r, d, l, u;
  P() { r = d = l = u = false; }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  P p[5][5];
  for (int i = 0; i < 9; i++) {
    cin >> s;
    if (i & 1) {
      for (int j = 0; j < 5; j++) {
        if (s[j] == '1') p[i / 2][j].d = p[i / 2 + 1][j].u = true;
      }
    } else {
      for (int j = 0; j < 4; j++) {
        if (s[j] == '1') p[i / 2][j].r = p[i / 2][j + 1].l = true;
      }
    }
  }
  string ans = "R";
  int y = 0, x = 1, d = 0;
  while (!(y == 0 && x == 0)) {
    if (d == 0) {
      if (p[y][x].u) y--, d = 3, ans += 'U';
      else if (p[y][x].r) x++, d = 0, ans += 'R';
      else if (p[y][x].d) y++, d = 1, ans += 'D';
      else x--, d = 2, ans += 'L';
    } else if (d == 1) {
      if (p[y][x].r) x++, d = 0, ans += 'R';
      else if (p[y][x].d) y++, d = 1, ans += 'D';
      else if (p[y][x].l) x--, d = 2, ans += 'L';
      else y--, d = 3, ans += 'U';
    } else if (d == 2) {
      if (p[y][x].d) y++, d = 1, ans += 'D';
      else if (p[y][x].l) x--, d = 2, ans += 'L';
      else if (p[y][x].u) y--, d = 3, ans += 'U';
      else x++, d = 0, ans += 'R';
    } else {
      if (p[y][x].l) x--, d = 2, ans += 'L';
      else if (p[y][x].u) y--, d = 3, ans += 'U';
      else if (p[y][x].r) x++, d = 0, ans += 'R';
      else y++, d = 1, ans += 'D';
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3120
#include<stdio.h>

int main(void)
{
    int n;
    int ai[10000];
    int min;
    int max;
    long int sum = 0;
    scanf("%d", &n);
    int i;
    for(i=0;i < n; i++)
    {
	scanf("%d",&ai[i]);
    }
	
    for(i = 0; i < n; i++)
    {
        if(i == 0)
        {
            min = ai[0];
            max = ai[0];
        }
        
        if(ai[i] < min)
        {
            min = ai[i];
        }
        
        if(ai[i] > max)
        {
            max = ai[i];
        }
        
        sum += ai[i];
    }
    printf("%d %d %ld\n", min, max, sum);

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;

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

	return gcd(b, a % b);
}

P lcm(int a, int b) {
	int g = gcd(a, b);

	return P(g, a / g * b);
}

int main() {
	char s[1000];
	while (1) {
		string str;
		if ( !getline(cin, str) ) break;

		for (int i = 0; i < str.size(); ++i)
			s[i] = str[i];
		s[str.size()] = '\0';

		int a, b;
		sscanf(s, "%d%d", &a, &b);

		P p = lcm(a, b);

		cout << p.first << " " << p.second << endl;
	}
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define ll long long
#define ss second
#define ff first
#define w(x) ll x; cin>>x; while(x--)
#define pi acos(-1)
#define all(cont) cont.begin(), cont.end()
#define countbit(x) __builtin_popcount(x)
#define mod 1000000007
#define re(i,n) for(ll i=0;i<n;i++)
#define re1(i,n) for(ll i=1;i<n+1;i++)
#define de(n) ll n;cin>>n;
#define def(a,n) ll n;cin>>n;ll a[n];re(i,n){cin>>a[i];}
#define defi(a,n,k) ll n;cin>>n; ll k;cin>>k;ll a[n];re(i,n){cin>>a[i];}
#define deb(x) cout<<#x<<"="<<x<<endl;
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define nl cout<<endl;
using namespace std;
//18-1326D1 1208B 845C 912B 1009B 1350C 20C 1333C 1234D 1327C 1305B 1304B (or in matrix) 1216-C(26) 21
void cp()
{
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    #ifndef ONLINE_JUDGE  
    freopen("input.txt", "r", stdin);  
    freopen("output.txt", "w", stdout);
#endif
}
int main()
{
  cp();
  //w(x)
  {
    ll l=0;
    de(n);
    bool g=0;
    re(i,n)
    {
      de(x);de(y);
      if(x==y)
      {
        l++;
      }
      else
      {
        l=0;
      }
      if(l>=3)
      {
        g=1;
      }
    }
    if(g==1)
    cout<<"Yes\n";
    else
    {
      cout<<"No\n";
    }
    
  }
}

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

int main() {
  string s;
  int pos;
  cin >> s >> pos;

  vector<string> t;

  for (int k = 0; k < (int)s.size(); k++) {
    for (int l = 1; l <= 5; l++) {
      t.push_back(s.substr(k, l));
    }
  }
  sort(t.begin(), t.end());
  unique(t.begin(), t.end());
  cout << t[pos-1] << endl;
}

Measured memory_bytes: 1660
#include <stdio.h>


int main(void) {
  char tenki[3];
  scanf("%s",tenki);
  int ans = 0;
  
    for(int i = 0; i < 3; i++){
      	if(tenki[0] == 'R' && tenki[1] == 'R' && tenki[2] == 'R')
        {
          	ans = 3;
        }
      	else if(tenki[0] == 'R' && tenki[2] == 'R')
        {
          	ans = 1;
        }
        else if(tenki[i] == 'R'){
            ans = ans + 1;
        }
    }
	
  
    printf("%d\n",ans);
    return 0;
}

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

int main (){
    int r;
    cin >> r;
    if(r < 1200){
        cout << "ABC";
    }else if(r <2800){
        cout << "ARC";
    }else{
        cout << "AGC";
    }
}


Measured memory_bytes: 256
x=[1,3,5,7,8,10,12]
y=[4,6,9,11]
a,b=map(int,input().split())
if a==2 or b==2:
    print('No')
elif a in x and b in x:
    print('Yes')
elif a in y and b in y:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

bool compare(string a, string b) {
	return (a + b < b + a);
}

string smallest(string inputs[], int n) {
	sort(inputs, inputs + n, compare);
	string ans = "";
	rep(i, n) {
		ans += inputs[i];
	}
	return ans;
}

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

	ll n = 0, l = 0;
	cin >> n >> l;
	string inp;
	string strings[n];
	rep (i, n) {
		cin >> inp;
		strings[i] = inp;
	}
	cout << smallest(strings, n);
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

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

    VL L(N+2, 0), R(N+2, 0);
    rep(i, 0, N){
        if(S[i] == '('){
            L[i+1] = L[i] + 1;
        }else{
            if(L[i] > 0) L[i+1] = L[i] - 1;
        }
    }
    for(ll i = N-1; i >= 0; i--){
        if(S[i] == '('){
            if(R[i+2] > 0) R[i+1] = R[i+2] - 1;
        }else{
            R[i+1] = R[i+2] + 1;
        }
    }

    /*
    rep(i, 1, N+1) cerr << L[i] << " ";
    cerr << endl;
    rep(i, 1, N+1) cerr << R[i] << " ";
    cerr << endl;
    */

    rep(i, 0, R[1]) cout << "(";
    cout << S;
    rep(i, 0, L[N]) cout << ")";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
from math import ceil
N = int(input())

def ceil_N(a,b):
  if a%b == 0:
    return a//b
  else:
    return a//b +1
  
T, A = 1,1
for i in range(N):
  t, a = map(int, input().split())

  #N = max(ceil(T/t), ceil(A/a))
  N = max(ceil_N(T,t), ceil_N(A,a))

  T = t * N
  A = a * N
  
print(T+A)

Measured memory_bytes: 3060
// Problem : 
// 			C - Five Transportations
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 123
// URL : https://atcoder.jp/contests/abc123/tasks/abc123_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef unsigned long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

int main(){
    IOS;
    ll n,num; cin >> n;
	ll mn = INF, ans;
	rep(i,0,5){
		cin >> num;
		mn = min(mn , num);
	}
	ans = (n/mn) + 5;
	ans = ans - (mn==1);
	cout << ans;
}


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

int main () {
  int n;
  cin >> n;
  int  a, b, c, d;
  a = n/1000%10;
  b = n/100%10;
  c = n/10%10;
  d = n%10;
  bitset<3> ans;
  for (int i = 0; i < 1 << 3; i++) {
    int sum = a + b + c + d;
    bitset<3> btst(i);
    if (btst[2] == 0) sum -= 2*b;
    if (btst[1] == 0) sum -= 2*c;
    if (btst[0] == 0) sum -= 2*d;
    if (sum == 7) ans = btst;
  }
  char op1 = '+', op2 = '+', op3 = '+';
  if (ans[2] == 0) op1 = '-';
  if (ans[1] == 0) op2 = '-';
  if (ans[0] == 0) op3 = '-';
  cout  << a << op1 << b << op2 << c << op3 << d << "=7" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1000000007; 
const int INF = 1000000000; //1e9
const int NIL = -1;
const long long LINF = 1000000000000000000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}




int main(){
    int N; std::cin >> N;
    std::vector<std::vector<int>> p(4, std::vector<int>(N));
    for(int i(0); i < N; ++i){
        std::cin >> p[0][i];
        for(int j(1); j < 4; ++j)
            p[j][i] = p[0][i];
    }
    int ans(INF);
    for(int lt(0); lt < 4; ++lt){//左端をlt回
        if(p[lt][0] < lt) continue;
        int cnt(lt);
        p[lt][0] -= lt;
        for(int i(0), i_len(N-1); i < i_len; ++i){
            int mx(std::max(p[lt][i], 0));
            cnt += 2 * mx;
            p[lt][i+1] -= mx;
        }
        cnt += std::max(p[lt][N-1], 0);
        chmin(ans, cnt);
    }
    std::cout << ans << std::endl;
    return 0;
}



Measured memory_bytes: 3236
#include<iostream>
using namespace std;
int main(){
    int N, M,i,j;
    int h[1500][1500] = { 0 }, l[1500] = { 0 }, t[1500] = { 0 };
    cin >> N >> M;
    for (i = 0; i < N; i++){
        cin >> l[i];
    }
    for (j = 0; j < M; j++){
        cin >> t[j];
    }
    for (j = 0; j < N; j++){
        for (i = j; i < j + M-N+1; i++){
            if (j == 0){
                h[j][i] = l[j] * t[i];
                if (h[j][i] >= h[j][i - 1] && i != 0){
                    h[j][i] = h[j][i - 1];
                }
            }
            else{
                h[j][i] = h[j - 1][i - 1] + l[j] * t[i];
                if (h[j][i] >= h[j][i - 1] && i != j){
                    h[j][i] = h[j][i - 1];
                }
            }
        }
    }
    cout << h[N - 1][M - 1] << endl;
    return 0;
}

Measured memory_bytes: 11884
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int x = scan.nextInt();
		if (x < 1200)
			System.out.println("ABC");
		else
			System.out.println("ARC");
	}
	
    
}






	

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

struct shop{
    long long price;
    int limit;
};

int main(){
    priority_queue<pair <long long, int> > PQ;
    int N, M;
    long long A, ans = 0;
    int B;
    cin >> N >> M;
    struct shop shop[N];
    for(int i = 0; i < N; i++){
        scanf("%lld %d", &A, &B);
        PQ.push(make_pair(-A, B));
    }
    int k = 0;
    pair<long long, int> f;
    while(1){
        f = PQ.top(); PQ.pop();
        if(k + f.second < M){
            ans += -f.first * f.second;
            k += f.second;
        }else{
            ans += -f.first * (M - k);
            break;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2420
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, a, b = map(int, input().split())
    if (a > b) or (n==1 and a<b):
        print(0)
    elif n == 1 and a == b:
        print(1)
    else:
        print(n*(b-a)+2*(a-b)+1)
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: u64 = sc.cin();
    put!((1..=n).filter(|i| i%3!=0 && i%5!=0).sum::<u64>())
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 2156
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

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

	int count = 0;
	for (int i = 0; i < N - 2; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			count++;
		}
	}

	cout << count << endl;
	return 0;
}

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

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a == b && b != c && c != a
    || a != b && b != c && c == a
    || a != b && b == c && c != a)
    cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256