akhauriyash/Code-Regression huggingface dataset:
import os
import sys
from io import BytesIO, IOBase
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------------------

from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list(map(int, sys.stdin.readline().rstrip().split()))
def N(): return int(input())
def comb(n, m): return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0
def perm(n, m): return factorial(n) // (factorial(n - m)) if n >= m else 0
def mdis(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

# ------------------------------
# f = open('../input.txt')
# sys.stdin = f

def main():
    n, k = RL()
    arr = RLL()
    arr.sort()
    print(sum(arr[:k]))


if __name__ == "__main__":
    main()



Measured memory_bytes: 67296
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
    // template start ---8<-----------8<---
	FastScanner sc = new FastScanner(System.in);
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		out = new PrintWriter(System.out);
		new Main().solve();
		out.flush();
	}
	// template end ---8<-----------8<---

	void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if (Math.abs(a-b)<=d && Math.abs(c-b)<=d || Math.abs(a-c)<=d) {
			out.println("Yes");
		} else {
			out.println("No");
		}

	}

    // template start ---8<-----------8<---
	class FastScanner {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		FastScanner(InputStream in) {
			this.in = in;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
				throw new NumberFormatException();
			return (int) nl;
		}

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

	class Random {
		private long seed;
		private final long multiplier = 0x5DEECE66DL, addend = 0xBL, mask = (1L << 48) - 1;
		int bits, val;

		Random(long seed) {
			this.seed = seed;
		}

		int nextInt(int n) {
			do {
				bits = (int) ((seed = (seed * multiplier + addend) & mask) >>> 17);
				val = bits % n;
			} while (bits - val + (n - 1) < 0);
			return val;
		}

		double nextDouble() {
			return nextInt(10000000) / 10000000.0;
		}
	}

	final double TEMP = 10;
	static final long TL = 5850;
	static boolean submit = true;
    // template end ---8<-----------8<---

}



Measured memory_bytes: 20052
#include<stdio.h>
int main(){
long long int H,N;
 scanf("%llu%llu",&H,&N);
 long long int i,arr[N],sum=0;
  for(i=0;i<N;i++)
  {scanf("%llu",&arr[i]);
  sum+=arr[i];}
  if(sum>=H)
    printf("Yes");
  else
    printf("No");

}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=2e5+5;
int n,nxt[MN][26],f[MN];
char S[MN];
int main(){
	scanf("%s",S+1);n=strlen(S+1);
	memset(nxt,-1,sizeof(nxt));
	for(reg int i=n;i;i--)
		for(reg int j=0;j<26;j++)
			nxt[i][j]=(S[i]==j+'a'?i:nxt[i+1][j]);
	memset(f,0x3f,sizeof(f));
	for(reg int i=n;i;i--){
		for(reg int j=0;j<26;j++){
			if(nxt[i][j]==-1){f[i]=1;break;}
			f[i]=min(f[i],f[nxt[i][j]+1]+1);
		}
	}
	reg int len=f[1],pos=1;
	while(len--){
		if(!len)for(reg int i=0;i<26;i++)
				if(nxt[pos][i]==-1)return 0*putchar(i+'a');
		for(reg int i=0;i<26;i++)
			if(f[pos]==f[nxt[pos][i]+1]+1){
				pos=nxt[pos][i]+1;
				putchar(i+'a');break;
			}
	}
	return 0;
}

Measured memory_bytes: 21504
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

  if(a > x) cout << "NO" << endl;
  else{
    if(a == x) cout << "YES" << endl;
    else if((a+b) < x) cout << "NO" << endl;
    else cout << "YES" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextString()
	n = strings.Replace(n, "1", "x", -1)
	n = strings.Replace(n, "9", "1", -1)
	n = strings.Replace(n, "x", "9", -1)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fprintf(out, n)
	fmt.Fprintf(out, "\n")
	out.Flush()
}
func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func Abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

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

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

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll c(ll a){
    return a * a * a * a * a;
}
int main() {
    init();
    ll a,b;
    ll X;
    cin >> X;

    bool isok = false;
    repe(i,-200,200){
        repe(j,i+1,201){
            ll d = c(j) - c(i);
            if(d==X){
                // err(d, j, i);
                a = j, b = i;
                isok = true;
                break;
            }
        }
        if (isok) break;
    }
    cout << a << " " << b << endl;
}

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

using namespace std;

string n;
int arr[1000010];
int dp[2][100010];

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

	reverse(n.begin(), n.end());

	for(int i = 0; i < (int) n.size(); i++){
		arr[i] = n[i] - '0';
	}

	dp[0][0] = arr[0];
	dp[1][0] = 10 - arr[0];

	for(int i = 1; i < (int) n.size(); i++){
		dp[0][i] = dp[0][i - 1] + arr[i];
		dp[1][i] = dp[0][i - 1] + 10 - arr[i];

		if(arr[i] < 9) dp[0][i] = min(dp[0][i], dp[1][i - 1] + arr[i] + 1), dp[1][i] = min(dp[1][i], dp[1][i - 1] + 10 - (arr[i] + 1));
		else dp[1][i] = min(dp[1][i], dp[1][i - 1]);
	}

	cout << min(dp[0][n.size() - 1], dp[1][n.size() - 1] + 1) << "\n";

	return 0;
}

Measured memory_bytes: 6044
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

struct node{
    string str;
    int cc[25];
    node(string in){
        str = in;
        for(int i = 0;i < 25;i++){
            cc[i] = 0;
        }
    }
    node(struct node* in){
        str = in->str;
        for(int i = 0;i < 25;i++){
            cc[i] = in->cc[i];
        }
    }
    node(struct node* in,int n,int c){
        str = in->str;
        for(int i = 0;i < 25;i++){
            cc[i] = in->cc[i];
        }
        str[n] = (char)str[n]+1;
        cc[c]++;
    }
};

int main(void){
    string strin;
    int i,j,k;
    char c;
    while(1){
        cin >> strin;
        if(strin[0] == '#') break;
        vector<node> re[21];
        re[0].push_back(new node(strin));
        for(i = 0;i < strin.length();i++){
            for(j = 0;j < re[i].size();j++){
                c = re[i][j].str[i];
                if(c == 'a') re[i+1].push_back(new node(&re[i][j]));
                else if(re[i][j].cc[c-'b'] == 1) re[i+1].push_back(new node(&re[i][j]));
                if(c != 'z'){
                    if(re[i][j].cc[c-'a'] == 0){
                        re[i+1].push_back(new node(&re[i][j],i,c-'a'));
                    }
                }
            }
        }
        k = re[i].size();
        cout << k << endl;
        if(k < 11){
            for(j = 0;j < k;j++){
                cout << re[i][j].str << endl;
            }
        }
        else{
            for(j = 0;j < 5;j++){
                cout << re[i][j].str << endl;
            }
            for(j = k-5;j < k;j++){
                cout << re[i][j].str << endl;
            }
        }
    }
}

Measured memory_bytes: 47924
import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
n = II()
a = LI()
q = II()
d = [0]*(10**5+1)
s = 0
for i in a:
	d[i]+=1
	s+=i
for j in range(q):
	b,c = MI()
	s+=(c-b)*d[b]
	d[c]+=d[b]
	d[b] = 0
	print(s)



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

using namespace std;
 long long n, a[200005], f[200005]={};
int main() {
   
    long long s = 0;
    cin >> n;
    for( int i = 1; i <= n; i++ ){
        cin >> a[i];
        f[a[i]]++;
    }
    for( int i = 1; i <= 200000; i++ ){
        if( f[i] != 0 ){
            s += (f[i]-1) * f[i] / 2;
        }
    }
    long long y = s;
    for( int i = 1; i <= n; i++ ){
        y = s;
        int x=a[i];
        y -= f[x]*(f[x]-1)/2;
        y +=(f[x]-1) * (f[x]-2) / 2;
        cout << y << endl;
    }
}

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

int main(){
	int m=0,f=0,r=0;

	while(1){
		cin >> m >> f >> r;
		if(m==-1&&f==-1&&r==-1){
			break;
		}
		if(m==-1||f==-1){
			cout << "F" << endl;
		}else if(m+f>=80){
			cout << "A" << endl;
		}else if(80>m+f&&m+f>=65){
			cout << "B" << endl;
		}else if(65>m+f&&m+f>=50){
			cout << "C" << endl;
		}else if(50>m+f&&m+f>=30){
			if(r>=50){
				cout << "C" << endl;
			}else{
				cout << "D" << endl;
			}
		}else{
			cout << "F" << endl;
		}



	}



return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol,lol>;
typedef vector<int> vit;

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  lol n, m;
  cin >> n >> m;
  priority_queue<pii, vector<pii>,greater<pii> > ab;
  lol a, b;
  rep(i, n){
    cin >> a >> b;
    ab.emplace(a, b);
  }
  lol ans = 0;
  while(m > 0){
    a = ab.top().fi;
    b = ab.top().se;
    ab.pop();
    ans += a * min(m, b);
    m -= min(m, b);
    //  cout << a << " " << b << '\n';
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 2420
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int r = scan.nextInt();
        int d = scan.nextInt();
        int x = scan.nextInt();
        int out = 0;
        for(int i = 0; i < 10; i++){
            out = r * x - d;
            System.out.println(out);
            x = out;
        }
    }
}

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

int main(){
  string S;
  cin >> S;
  string a="hi";
  string b="hihi";
  string c="hihihi";
  string d="hihihihi";
  string e="hihihihihi";
  if(S==a || S==b || S==c || S==d || S==e){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

int c[2000000] = {0};

int f(int n) {
  if (n % 2 == 0) {
    return n/2;
  }
  else {
    return 3*n + 1;
  }
}

int main() {
  int s;
  cin >> s;
  c[s]++;
  int a = s;
  int i = 1;

  while (true) {
    i++;
    a = f(a);
    c[a]++;
    if (c[a] >= 2) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() 
{
    int a, b, c, i, ans;
    cin >> a >> b >> c;
    ans = 0;
    for(i=a; i<=b; i++)
    {
        if(c % i == 0)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i, p, n, k, k_tmp, w, w_sum = 0, p_tmp, p_pr = 1000000000;
    int *ws;

    scanf("%d %d", &n, &k);
    ws = malloc(sizeof(int) * n);
    for(i = 0; i < n; i++) {
        scanf("%d", &w);
        w_sum += (ws[i] = w);
    } 
    p = w_sum / k;
    w_sum = 0;
    k_tmp = k;
    do {
        p_tmp = -1;
        w_sum = 0;
        for(i = 0; k_tmp > 1; i++) {
            w_sum += ws[i];
            if(w_sum == p) {
                k_tmp--;
                p_tmp = p_tmp < w_sum ? w_sum : p_tmp;
                w_sum = 0;
            } else if(w_sum > p) {
                k_tmp--;
                p_tmp = p_tmp < w_sum - ws[i] ? w_sum - ws[i] : p_tmp;
                i--;
                w_sum = 0;
            }
        }
        for(; i < n; i++) w_sum += ws[i];
        p_tmp = p_tmp < w_sum ? w_sum : p_tmp;
        if(p_tmp == p) {
            printf("%d\n", p);
            return 0;
        }
        if(p_tmp < p_pr)
            p_pr = p_tmp;
        k_tmp = k;
    } while(++p < p_pr);
    printf("%d\n", p_pr);

    return 0;
}

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

using namespace std;
#define local
#ifdef local

template<class T>
void _E(T x) { cerr << x; }

void _E(double x) { cerr << fixed << setprecision(6) << x; }

void _E(string s) { cerr << "\"" << s << "\""; }

template<class A, class B>
void _E(pair<A, B> x) {
    cerr << '(';
    _E(x.first);
    cerr << ", ";
    _E(x.second);
    cerr << ")";
}

template<class T>
void _E(vector<T> x) {
    cerr << "[";
    for (auto it = x.begin(); it != x.end(); ++it) {
        if (it != x.begin()) cerr << ", ";
        _E(*it);
    }
    cerr << "]";
}

void ERR() {}

template<class A, class... B>
void ERR(A x, B... y) {
    _E(x);
    cerr << (sizeof...(y) ? ", " : " ");
    ERR(y...);
}

#define debug(x...) do { cerr << "{ "#x" } -> { "; ERR(x); cerr << "}" << endl; } while(false)
#else
#define debug(...) 114514.1919810
#endif
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f3f3f
#define ll long long
#define db long double
#define eps 1e-3
#define bin(x) cerr << bitset<10>(x) << endl
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define endl "\n"
const ll mod = 1e9 + 7;
const ll maxn = 2e4 + 10;
const db pi = acos(-1.0);

ll qpow(ll a, ll b) {
    ll ret = 1;
    for (; b; a = a * a % mod, b >>= 1) {
        if (b & 1) {
            ret = ret * a % mod;
        }
    }
    return ret;
}

vector<ll> f(maxn), invf(maxn);

ll inv(ll a) {
    return qpow(a, mod - 2);
}

void prework() {
    f[0] = 1;
    _rep(i, 1, maxn - 1) {
        f[i] = f[i - 1] * i % mod;
    }
    invf[maxn - 1] = qpow(f[maxn - 1], mod - 2);
    for (ll i = maxn - 2; i >= 0; i--) {
        invf[i] = invf[i + 1] * (i + 1) % mod;
    }
}

ll C(ll n, ll m) {
    if (n > m || m < 0)return 0;
    if (n == 0 || m == n) return 1;
    ll res = (f[m] * invf[m - n] % mod * invf[n]) % mod;
    return res;
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n + 1), suf(n + 2);
    _rep(i, 1, n) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; i--) {
        suf[i] = (suf[i + 1] + a[i])%mod;
    }
    ll res = 0;
    _rep(i, 1, n) {
        res = (res + (a[i] * (suf[i + 1])) % mod) % mod;
    }
    cout << res << endl;
}

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

typedef long long lint;

int main(){
    lint N;
    lint A[100000];
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    lint diff=A[0]-A[N-1];
    for(int i=1;i<N;i++){
        if(diff<A[i]-A[i-1]) diff=A[i]-A[i-1];
    }

    lint A0=(diff-A[0]+A[N-1])/N;

    if((diff-A[0]+A[N-1])%N!=0){
        cout << "NO" << endl;
        return 0;
    }
    for(int i=1;i<N;i++){
        if((diff-A[i]+A[i-1])%N!=0){
            cout << "NO" << endl;
            return 0;
        }
        A0+=(N+1-i)*((diff-A[i]+A[i-1])/N);
    }
    if(A[0]>=A0 && (A[0]-A0)%(N*(N+1)/2)==0) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
char a[2000000];
int main(){
	int n,ans=0;cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	int i=0;
	int j=n-1;
	while(i<j){
		if(a[i]=='R') i++;
		else if(a[j]=='W') j--;
		else{
			ans++;i++;j--;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3824
N = int(input())
A = list(map(int, input().split()))
A.insert(0,0)
A.append(0)

sum = 0
for i in range(N+2):
    if i == 0:
        continue
    sum += abs(A[i] - A[i-1])
    

print
for i in range(1,N+1):
    if (A[i] - A[i-1])*(A[i+1] - A[i]) < 0:
        d = min(abs(A[i] - A[i-1]),abs(A[i+1] - A[i]))
        print(sum - 2*abs(d))
    else:
        print(sum)


Measured memory_bytes: 14048
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <vector>
#include <cstdlib>
#include <cstdio>

using namespace std;

struct edge{
	int start, target, weight;
};



int main(){
	int size;
	cin >> size;
	int num;
	cin >> num;

	int x;
	int y;
	while(cin >> x && cin >> y){
		if(x > size / 2) x = size - x + 1;
		if(y > size / 2) y = size - y + 1;
		
		int t = x < y ? x : y;
		//cout << t << endl;
		cout <<  (t + 2) % 3 + 1 << endl;

	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <string.h>
using namespace std;
int arr[60][60];
int ch[60][60];
struct ab{
int x,y,t;
};
queue <ab> q;
int main(){
    int i,a,b,j,k,sum=0; ab m,n;
    scanf("%d %d\n",&a,&b);
    for(i=1;i<=a;i++){
        char c[100],d; k=1;
        fgets(c,100,stdin);
        for(j=0;j<strlen(c);j++){
            if(c[j]=='.') {
                arr[i][k]=1; k++;
            }
                else if(c[j]=='#'){
                    arr[i][k]=0; k++; sum++;
                }
                else ;

        }

    }
    
    ch[1][1]=1; m.x=1; m.y=1; m.t=1;
    q.push(m);
    while(!q.empty()){
        m=q.front(); q.pop();
        if(ch[m.x+1][m.y]==0&&arr[m.x+1][m.y]==1){
            ch[m.x+1][m.y]++; n.x=m.x+1; n.y=m.y; n.t=m.t+1;
            q.push(n);
            if(n.x==a&&n.y==b){
                printf("%d",a*b-sum-n.t); return 0;
            }
        }
        if(ch[m.x-1][m.y]==0&&arr[m.x-1][m.y]==1){
            ch[m.x-1][m.y]++; n.x=m.x-1; n.y=m.y; n.t=m.t+1;
            q.push(n);
            if(n.x==a&&n.y==b){
                printf("%d",a*b-sum-n.t); return 0;
            }
        }
        if(ch[m.x][m.y+1]==0&&arr[m.x][m.y+1]==1){
            ch[m.x][m.y+1]++; n.x=m.x; n.y=m.y+1; n.t=m.t+1;
            q.push(n);
            if(n.x==a&&n.y==b){
                printf("%d",a*b-sum-n.t); return 0;
            }
        }
        if(ch[m.x][m.y-1]==0&&arr[m.x][m.y-1]==1){
            ch[m.x][m.y-1]++; n.x=m.x; n.y=m.y-1; n.t=m.t+1;
            q.push(n);
            if(n.x==a&&n.y==b){
                printf("%d",a*b-sum-n.t); return 0;
            }
        }


    }
printf("-1");


}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toInt() }
    val list = mutableListOf<Int>()
    for (i in 1..Math.min(a,b)) {
        if (a % i == 0 && b % i == 0) list.add(i)
    }
    println(list[list.size - k])
}



Measured memory_bytes: 36204
import java.util.*;
import java.io.*;
import java.lang.*;

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

		if (b%a == 0)
			System.out.println(a+b);
		else
			System.out.println(b-a);
	}
}


Measured memory_bytes: 35756
#include <stdio.h>
#include <ctype.h>
//#define DEBUG

int main(void){

		char ch;
		int cnt[26] = {};		//??????????????°?????°??????
		int i = 0 ;				//???????????°

		while ( scanf("%c", &ch) != EOF ){				//EOF?????§??????????¶???????

			if(isupper(ch)){
				ch = tolower(ch);	//??§?????????????°????????????????????????????????????????
			}

			if(islower(ch)){		//?°????????????????????????????????????????
				i = ch - 'a';		//ch???0-25?????°????????????
				cnt[i]++;			//????????????????´??????????????????¢??????
#ifdef DEBUG
//				printf("%c????????°???%d\n",i + 'a',cnt[i]);		//???????¢??????¨
#endif

			}


#ifdef DEBUG
			if(ch == '\n'){
				break;
			}
#endif

		}//?????????????????????????????§

		/*???????????????*/
		for(i = 0 ; i < 26 ; i++){
			printf("%c : %d\n",i + 'a' , cnt[i]);
		}

		return 0;
}

Measured memory_bytes: 548
while True:
  aopb = [x for x in input().split()]
  a = int(aopb[0])
  op = aopb[1]
  b = int(aopb[2])
  if op == '?':
    break
  elif op == '+':
    print(a + b)
  elif op == '-':
    print(a - b)
  elif op == '*':
    print(a * b)
  elif op == '/':
    print(a // b)

Measured memory_bytes: 7656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int N = 0; 
  for (int i = 0; i <= A; i++) {
   for (int j = 0; j <= B; j++) {
    for (int k = 0; k <= C; k++) {
  if(500 * i + 100 * j + 50 * k == X)
  N ++; 
    } 
   }
  }
  cout << N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <deque>
#include <algorithm>
#include <set>
#include <string>
#include <math.h>
#include <stdio.h>
#include<iomanip>
#include <cstring>


#define ll long long
using namespace std;
//const ll MOD = (int) 10e9 + 7;

/*ll dp[100001];
vector<vector<ll>>adj;
ll dfs(ll node)
{
    if (dp[node] != -1)
        return dp[node];

    ll ans = 0;
    for (int i = 0; i < adj[node].size(); i++)
    {
        ans = max(dfs(adj[node][i]) + 1, ans);

    }
    return dp[node] = ans;
}
*/
ll dp[3001][3001];
bool flag[3001][3001];
ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;

    return n * factorial(n - 1);
}
ll help(ll i, ll j, ll arr[], ll turn)
{
    if (i > j) return 0;
    if (flag[i][j])
        return dp[i][j];

    if (turn == 1)
    {
        dp[i][j] = max(arr[i] + help(i + 1, j, arr, -1 * turn), arr[j] + help(i, j - 1, arr, -1 * turn));
    }
    else
        dp[i][j] = min(help(i + 1, j, arr, -1 * turn) - arr[i],  (- 1 * arr[j]) + help(i, j - 1, arr, -1 * turn));

    flag[i][j] = true;
    return dp[i][j];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (ll i = 0; i < 3001; i++)
    {
        for (ll j = 0; j < 3001; j++)
            flag[i][j] = false;
    }
    cout << help(0, n  - 1, arr, 1);
    /*std::cout<<std::fixed;
    std::cout<<std::setprecision(10)<<ans;*/
    return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define MAXN 1000100
#define pii pair<int, int>
#define pb push_back
#define inf 1e18
#define fi first
#define se second
#define mt make_tuple
typedef long long ll;

using namespace std;

ll n, a[MAXN], mod = 1e9 + 7, ans;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    ll t = 1;
    for(int b = 0; b < 60; b++){
        int c = 0;
        for(int i = 0; i < n; i++){
            if((a[i] >> b) & 1) c++;                
        }
        ans += t * (((c * (n - c))) % mod);
        ans %= mod;
        t = (t * 2) % mod;
    }
    cout << ans;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int x, t;
  cin >> x >> t;
  cout << max(x - t, 0) << endl;
}



Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
longest = 0
prev = a[0]
for h in a[1:]:
    dif = h - prev
    prev = h
    if dif > longest:
        longest = dif
b = k - a[-1] + a[0]
if longest <= b:
    longest = b
print(k - longest)

Measured memory_bytes: 26420
#include<bits/stdc++.h>
typedef long long i64;
const int P=1e9+7,N=2e5+7;
int h,w,a,b;
i64 fac[N],fiv[N];
i64 pw(i64 a,i64 n){
	i64 v=1;
	for(;n;n>>=1,a=a*a%P)if(n&1)v=v*a%P;
	return v;
}
i64 cal(int a0,int b0,int a,int b){
	a-=a0,b-=b0;
	return fac[a+b]*fiv[a]%P*fiv[b]%P;
}
int main(){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	int mx=h+w;
	for(int i=fac[0]=1;i<=mx;++i)fac[i]=i*fac[i-1]%P;
	fiv[mx]=pw(fac[mx],P-2);
	for(int i=mx;i;--i)fiv[i-1]=i*fiv[i]%P;
	i64 ans=cal(1,1,h,w);
	for(int i=1;i<=b;++i){
		ans=(ans-cal(1,1,h-a,i)*cal(h-a+1,i,h,w))%P;
	}
	printf("%lld\n",(ans%P+P)%P);
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

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 == 1 && B == 2 || A==2 && B==1){
			System.out.println(3);
		}else if(A ==1 && B == 3 || A == 3 && B ==1){
			System.out.println(2);
		}else{
		System.out.println(1);
	}
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;   
const int mod = 1e9 + 7;
const int N = 1003;
const int M = 10003;
int power(int b, int exp){
    int res = 1;
    while(exp > 0){
        if(exp % 2){
            res = 1LL * res * b % mod;
        }
        b = 1LL * b * b % mod;
        exp /= 2;
    }
    return res;
}
int dp[N][M], b[N], a[N];
int fun(int idx, int lft){
    if(lft <= 0) return 0;
    if(idx == 0){
        return 1e9;
    }
    int &ret = dp[idx][lft];
    if(ret != -1) return ret;
    return ret = min(b[idx] + fun(idx, lft - a[idx]), fun(idx - 1, lft));
}
int main(){
    memset(dp, -1, sizeof(dp));
    int n, h;
    scanf("%d %d", &h, &n);
    for(int i = 1; i <= n; i++){
        scanf("%d %d", &a[i], &b[i]);
    }
    printf("%d\n", fun(n, h));
    return 0;
}

Measured memory_bytes: 39936
from heapq import heappush, heappop
import sys
r=sys.stdin.readline
def s(n,k):
 def g(S,G):
  F=[1e7]*-~n;F[S],H=0,[(0,S)]
  while H:
   c,u=heappop(H)
   if u==G:return c
   for f,v in E[u]:
    t=c+f
    if t<F[v]:F[v]=t;heappush(H,(t,v))
  return-1
 E=[[]for _ in[0]*-~n]
 for _ in[0]*k:
  f=r();p=map(int,f[2:].split())
  if'0'==f[0]:print(g(*p))
  else:c,d,e=p;E[c]+=[(e,d)];E[d]+=[(e,c)]
for e in iter(r,'0 0\n'):s(*map(int,e.split()))


Measured memory_bytes: 6272
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int sz;
char s[N], out[N];

int main(){
    scanf("%s", s);
    int n = strlen(s);
    for(int i = 0 ; i < n ; ++i){
        if(s[i] != 'B')out[sz++] = s[i];
        else sz = max(0, sz - 1);
    }
    out[sz] = '\0';
    printf("%s\n", out);
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>

struct Point { double x, y; };

void print(Point point) {
	printf("%.8f %.8f\n",point.x, point.y);
}

void koch(int n, Point a, Point b) {
	if (n == 0) return;
	Point s, t, u;
	double th = M_PI * 60.0 / 180.0;

	s.x = (2.0 * a.x + 1.0*b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0*b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0*b.x) / 3.0;
	t.y = (1.0*a.y + 2.0*b.y) / 3.0;
	u.x = (t.x - s.x)*cos(th) - (t.y - s.y)*sin(th) + s.x;
	u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;

	koch(n - 1, a, s);
	print(s);
	koch(n - 1, s, u);
	print(u);
	koch(n - 1, u, t);
	print(t);
	koch(n - 1, t, b);
}

int main(void) {
	Point a, b;
	int n;

	scanf("%d", &n);
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;

	print(a);
	koch(n, a, b);
	print(b);

	return 0;
}


Measured memory_bytes: 2704
line = "#." * 151

loop do
  h, w = gets.chomp.split(" ").map(&:to_i)
  break if h == 0 && w == 0
  h.times do |i|
    if i % 2 == 1 then
      puts line[1..w]
    else
      puts line[0..w-1]
    end
  end
  puts ""
end

Measured memory_bytes: 8724
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <complex>
using namespace std;

int main() {
    string s;
    cin >> s;
    for(int i = 1; i < s.size(); i++){
        int k = s.size() - i;
        if( s.substr(0, k / 2) == s.substr( k / 2, k / 2 )){
            cout << s.size() - i - 1 << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int MAX=2e5+10;
char str[MAX];
int main(){
    while(~scanf("%s",str)){
        ll ans=0,b=0;
        for(int i=0;str[i];i++){
            if(str[i]=='B') b++;
            else ans+=b;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
/* Author : Ravikumar Navale */
#define fastIo() ios_base :: sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define pb push_back
#define endl  "\n"
typedef long long int ll;
vector<pair<ll,ll> >v1, v2, v3;
const ll MOD = 1e9 + 7;
const double peek = 1e7 ;

int main()
{
    fastIo();
    ll N;
    cin>> N;
    ll A[N+1];
    ll DP[N+1];
    for(ll  i = 1;  i <=N ; i++)
    {
        cin >>A[i];
        DP[i] = 0;
    }
    
    DP[0] = 0;
    DP[2] = abs(A[2] - A[1]);
    
    for(ll i= 3 ; i <= N ; i++ )
    {
        DP[i] = min(abs(A[i]-A[i-1]) + DP[i-1], abs(A[i] - A[i-2]) + DP[i-2]);
    }
    
    cout << DP[N] ;
    
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <stdlib.h>
#include <complex>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)++)
#define p(...) printf(__VA_ARGS__); cout << endl;
#define input(x) x; cin >> x;
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](const a, const b){ return c ;}
#define key(t, x, compare) [](const t& a, const t& b){ return a x compare b x ;}

using namespace std;

using pii = pair<int, int>;

int main(){
  string input(a);
  string input(b);
  double result = sqrt(atoi((a + b).c_str()));
  cout << (result == int(result) ? "Yes" : "No") << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n, x, y;
    int xdis, ydis;
    double allsum = 0, sum = 0, cnt = 0;
    cin >> n;
    vector<int>cityNumber(n);
    iota(all(cityNumber), 1);
    vector<pi>city;
    rep(i, n) {
        cin >> x >> y;
        city.push_back(make_pair(x, y));
    }
    do {
        sum = 0;
        rep(i, n - 1) {
            xdis = city[cityNumber[i] - 1].first - city[cityNumber[i + 1]-1].first;
            ydis = city[cityNumber[i] - 1].second - city[cityNumber[i + 1]-1].second;
            sum += sqrt((xdis * xdis) + (ydis * ydis));
        }
        allsum += sum;
        cnt++;
    } while (next_permutation(all(cityNumber)));

    cout << fixed << setprecision(12) << allsum/cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
typedef vector<vector<ll>> matrix;

// ACCGA

const int MOD = 1000000007;

matrix mult(matrix a, matrix b) {
  matrix c;
  for(int i = 0; i < a.size(); i++) {
    c.push_back({});
    for(int j = 0; j < b[0].size(); j++) {
      c[i].push_back(0);
      for(int k = 0; k < b.size(); k++) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= MOD;
      }
    }
  }
  return c;
}

void solve() {
  matrix base;
  for(int i = 0; i < 64; i++) {
    vector<ll> t;
    for(int j = 0; j < 64; j++) t.push_back(0);
    base.push_back(t);
  }
  // a is 0, c is 1, g is 2, t is 3
  // AGC
  // GAC
  // ACG
  for(int a = 0; a < 4; a++) for(int b = 0; b < 4; b++) for(int c = 0; c < 4; c++) for(int d = 0; d < 4; d++) {
    if(a == 0 && b == 2 && c == 1) continue;
    if(a == 0 && b == 2 && d == 1) continue;
    if(a == 0 && c == 2 && d == 1) continue;
    if(b == 0 && c == 2 && d == 1) continue;

    if(a == 2 && b == 0 && c == 1) continue;
    if(a == 0 && b == 1 && c == 2) continue;

    if(b == 2 && c == 0 && d == 1) continue;
    if(b == 0 && c == 1 && d == 2) continue;

    base[16*a+4*b+c][16*b+4*c+d] = 1;
  }
  int n;
  cin >> n;
  n -= 3;
  matrix other;
  for(int i = 0; i < 64; i++) {
    other.push_back({1});
  }
  other[16*0+4*2+1*1][0] = 0;
  other[16*2+4*0+1*1][0] = 0;
  other[16*0+4*1+1*2][0] = 0;
  while(n--) {
    other = mult(base, other);
  }
  ll ret = 0;
  for(auto out: other) ret += out[0];
  cout << ret%MOD << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int a,m,i;
    scanf("%d%d",&a,&m);

      if(a%3==0||m%3==0||(a+m)%3==0){
          printf("Possible\n");
      }
      else{
          printf("Impossible\n");
      }
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        while (true) {
            int m = input.nextInt(); //中間
            int f = input.nextInt(); //期末
            int r = input.nextInt(); //再試験
            if (m == -1 && f == -1 && r == -1) break;
            
            char result;
            if (m == -1 || f == -1) result = 'F';
            else if (m + f >= 80) result = 'A';
            else if (m + f >= 65) result = 'B';
            else if (m + f >= 50) result = 'C';
            else if (m + f >= 30) {
                if (r >= 50) result = 'C';
                else result = 'D';
            } else result = 'F';
            
            System.out.println(result);
        }
    }
}

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


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B < C + D) {
    cout << "Right" << endl;
  }
  
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Left" << endl;
  }
}  


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, a, b;cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
    return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

template< typename T >
size_t longest_increasing_subsequence(const vector< T > &a, bool strict) {
  vector< int > lis;
  for(auto &p : a) {
    typename vector< T >::iterator it;
    if(strict) it = lower_bound(begin(lis), end(lis), p);
    else it = upper_bound(begin(lis), end(lis), p);
    if(end(lis) == it) lis.emplace_back(p);
    else *it = p;
  }
  return lis.size();
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  cout << longest_increasing_subsequence(A, true) << endl;
}




Measured memory_bytes: 3864
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    if (b > c) swap(b, c);
    if (a > b) swap(a, b);
    int p = b-a, q = c-b, ans = 0;
    if((a|b|c)&1){
        cout << 0 << "\n";
        return 0;
    }
    if(p == 0 && q == 0){
        cout << -1 << "\n";
        return 0;
    }
    else if(p == 0){
        p = q;
    }else if(q == 0){
        q = p;
    }
    p = __gcd(p, q);
    while(p%2 == 0){
        p/=2;
        ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
a,b,c = map(int,input().split())
k = int(input())
check = True
while b <= a:
  if k == 0:  
    check = False
    break
  b = 2*b
  k -= 1
  
while b >= c:
  if k == 0:
    check = False
    break
  c = 2*c
  k -= 1
  
if check == True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9188
N,M=map(int,input().split())
A=list(map(int,input().split()))
CB=[[0,0] for _ in range(M)]

for i in range(M):
    CB[i][1],CB[i][0]=map(int,input().split())
    
A.sort()
CB.sort(reverse=True)

#Aを小さい順に見る，Cが大きい順に変更操作をして確定していく
cc=0
ans=0
for i in range(N):
    if cc<M:
        if A[i]<CB[cc][0]:
            A[i]=CB[cc][0]
            CB[cc][1]-=1
            if CB[cc][1]==0:
                cc+=1
    ans+=A[i]
        
print(ans)

Measured memory_bytes: 73752
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;


int main(int argc, char *argv[]) {
	int a, b;
	cin >> a >> b;
	string s1 = string(a, '0' + b);
	string s2 = string(b, '0' + a);

	long long int n1 = stoll(s1), n2 = stoll(s2);
	if (n1 > n2)
		cout << n1 << endl;
	else
		cout << n2 << endl;
}









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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  rep(i, W + 2) cout << "#";
  cout << endl;

  char a;
  rep(i, H) {
    cout << "#";
    rep(j, W) {
      cin >> a;
      cout << a;
    }
    cout << "#" << endl;
  }

  rep(i, W + 2) cout << "#";
  cout << endl;

  return 0;
}


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

typedef long long ll;

const int N = 1e5 + 5, mod = 1e9 + 7;
int bt[N];

ll fact[N], ifact[N];

ll mod_inverse(ll a, ll b)
{
    ll ret = 1ll;
    for(;b ; b >>= 1)
    {
        if(b&1) ret = (ret * a) % mod;
        a = (a * a) % mod;
    }
    return ret % mod;
}



void calc()
{
    fact[0] = fact[1] = 1;

    ifact[0] = 1;
    ifact[1] = 1;

    for(int i = 2; i < N; i++)
    {
        fact[i] = (fact[i - 1] * i) % mod;
        ifact[i] = (ifact[i - 1] * mod_inverse(i, mod - 2) ) % mod;
    }
}


ll nCr(int n, int r)
{
    if(r > n) return 0;
    return (1ll * fact[n] * (( ifact[r] * ifact[n - r] ) % mod) ) % mod;
}





int main()
{
    calc();


    int n;
    scanf("%d", &n);
    int d = 0;

    for(int i = 1; i <= n + 1; i++)
    {
        int x;
        scanf("%d", &x);
        if(bt[x] != 0)
        {
            d = n - i + bt[x];
        }
        bt[x] = i;
    }


    for(int i = 1; i <= n + 1; i++)
    {
        ll res = nCr(n + 1, i) - nCr(d, i - 1);
        if(res < 0) res += mod;
        printf("%lld\n", res);
    }

}


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

int main(){
    int n;
    while(cin>>n,n){
        vector<pair<int,int> >vec;
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            vec.push_back(make_pair(b, a));
        }
        sort(vec.begin(),vec.end());
        int all=0;
        bool o=true;
        for(int i=0;i<vec.size();i++){
            all+=vec[i].second;
            if(all>vec[i].first){
                o=false;
                cout<<"No"<<endl;
                break;
            }
        }
        if(o)cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
 
int main(){
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    if(a>=b && b>=c){
        cout << c << " " << b << " " << a << endl;
    }else if(b>=a && a>=c){
        cout << c << " " << a << " " << b << endl;
    }else if(c>=a && a>=b){
        cout << b << " " << a << " " << c << endl;
    }else if(a>=c && c>=b){
        cout << b << " " << c << " " << a << endl;
    }else if(b>=c && c>=a){
        cout << a << " " << c << " " << b << endl;
    }else if(c>=b && b>=a){
        cout << a << " " << b << " " << c << endl;
    
    }
    return 0;
}


Measured memory_bytes: 3056