akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <fstream>
#include <cstring>
#include <stack>

using namespace std;

#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double

const ld pi = acos(-1);

template<typename T>
T abs(T x) {
    return x > 0 ? x : -x;
}

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

template<typename T>
ostream& operator << (ostream &s, const vector<T> &x) {
    s << "[";
    for (auto it : x) {
        s << it << ", ";
    }
    s << "]";
    return s;
}

template<typename T>
ostream& operator << (ostream &s, const set<T> &x) {
    s << "{";
    for (auto it : x) {
        s << it << ", ";
    }
    s << "}";
    return s;
}


template<typename U, typename V>
ostream& operator << (ostream &s, const pair<U, V> &x) {
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}

template<typename T>
bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

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

const int maxn = 2005;

ll dp[maxn][maxn];

int main() {
    srand(time(NULL));
    retry:
#ifdef LOCAL
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
#endif

    int n;
    ll x;
    cin >> n >> x;

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

    ll ans = 1e18;
    for (int i = 0; i <= n + 3; i++) {
        ll s = 0;
        for (int j = 0; j < n; j++) {
            s += a[j];
        }
        chmin(ans, i * x + s);
        vector<ll> b = a;
        for (int j = 0; j < n; j++) {
            b[j] = min(a[j], a[(j - 1 + n) % n]);
        }
        a = b;
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int n,cnt=0;
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a.at(i);
	for(int i=0;i<n-1;i++){
		if(a.at(i)  != i+1){
			cnt++;
		}
	}
	if(cnt>2){
		cout<<"NO"<<endl;
	}else{
		cout<<"YES"<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
import sys
import numpy as np


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    h, w = nm()
    A = np.array([list(ns()) for _ in range(h)])
    i = 0
    while i < len(A):
        if np.all(A[i] == '.'):
            A = np.delete(A, i, 0)
        else:
            i += 1

    j = 0
    while j < len(A[0]):
        if np.all(A[:, j] == '.'):
            A = np.delete(A, j, 1)
        else:
            j += 1
    for a in A:
        print(''.join(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum^=a[i];
    }

    rep(i,n){
        ll ans=sum^a[i];
        cout<<ans<<" ";
    }
    cout<<endl;
}



Measured memory_bytes: 4732
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
  string str;
  map<char,int> m;

  cin >> str;

  for(int i=0;i<str.size();i++){
    m[str[i]]++;
  }
  
  cout << min(m['K'],min(m['U'],min(m['P'],m['C']))) << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define   ll   long long int
#define   sz   200010

using namespace std;


ll num[sz];

int main()
{


    ll n,i,j,k,a,b,x,y,d,c,p;

    cin>>n;

    for(i=1;i<=n;i++)
    {
        cin>>num[i];
    }

    d=1;
    c=0;

    for(i=1;i<=n;i++)
    {
        if(num[i]==d)
        {
            d++;
        }
        else
            c++;
    }
    if(c==n)c=-1;

    cout<<c<<endl;


    return 0;
}


Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    a, b, x = [int(i) for i in input().strip().split()]
    b_x = b // x
    if a > 0:
        a_x = (a - 1) // x
    else:
        a_x = -1
    ans = b_x - a_x
    print(ans)
    return


if __name__ == "__main__":
    main()


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

int main(){
  string s;
  cin >> s;
  
  string t = "ATCG";
  
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    int now = 0;
    for(int j = i; j < s.size(); j++){
      bool ok = false;
      for(int k = 0; k < t.size(); k++){
        if(s[j] == t[k])
          ok = true;
      }
      if(ok){
        now++;
        ans = max(ans, now);
      }
      else{
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
#define all(v) v.begin(), v.end()
int main() {

string  S,T;
cin >>S>>T;
if(T.substr(0,S.size())==S){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long

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


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

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

int h, w;
vector<string> m;

int bfs() {

    vector<vector<int>> cost(h, vector<int>(w, -1));
    queue<pair<int, int>> que;

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (m[i][j]=='#') {
                que.push(pair<int, int>(i, j));
                cost[i][j] = 0;
            }
        }
    }

    while (!que.empty()) {
        auto cur = que.front();
        que.pop();
        for (int i=0; i<4; i++) {
            int ny = cur.first + dy[i];
            int nx = cur.second + dx[i];
            if (ny < 0 || ny >= h || nx < 0 || nx >= w || m[ny][nx] == '#') continue;
            if (cost[ny][nx] == -1 && m[ny][nx] == '.') {
                cost[ny][nx] = cost[cur.first][cur.second] + 1;
                que.push(pair<int, int>(ny, nx));
            }
        }
    }

    int ans = 0;
    for (int i=0; i<h; i++){
        for (int j=0; j<w; j++) {
            ans = max(ans, cost[i][j]);
        }
    }

    return ans;
}

int main(){
    
    cin >> h >> w;
    m.resize(h);
    for (int i=0; i<h; i++) cin >> m[i];
    
    cout << bfs() << endl;

    return 0;
}

Measured memory_bytes: 16976
def func(n, m, x, y, z):
    _max = -10**10
    for i in range(2):
        for j in range(2):
            for k in range(2):
                sign = ["+", "+", "+"]
                if i == 1:
                    sign[0] = "-"
                if j == 1:
                    sign[1] = "-"
                if k == 1:
                    sign[2] = "-"
                xyz = [eval("{}{}{}{}{}{}".format(sign[0], x[l],
                                      sign[1], y[l],
                                      sign[2], z[l])) for l in range(n)]
                xyz.sort()
                # print(xyz)
                _sum = sum(xyz[n-m:])
                _max = max(_max, _sum)
    return _max

n, m = [int(i) for i in input().split()]
x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
z = [0 for _ in range(n)]
for i in range(n):
    x[i], y[i], z[i] = [int(i) for i in input().split()]
print(func(n, m, x, y, z))
"""
print("print(func({}, {}, {}, {}, {}))".format(n, m, x, y, z))
print(56 == func(5, 3, [3, 1, 2, 3, 9], [1, 5, 6, 5, 7], [4, 9, 5, 8, 9]))
print(54 == func(5, 3, [1, -4, 7, -10, 13], [-2, 5, -8, 11, -14], [3, -6, -9, -12, 15]))
print(638 == func(10, 5, [10, 23, -94, -26, -69, -26, -72, 21, 40, -62], [-80, 8, 28, -2, 72, -86, -50, 65, -94, 18],
           [21, 38, 11, 18, 79, -54, 59, -32, 87, 82]))
"""


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

#define UN unsigned
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define pb push_back
//~ #define x first
//~ #define y second
const int N = 2e5 + 5;


void solve(){
	int n;
	cin >> n;

	if(n%1000 == 0) cout << 0 << endl;
	else cout << 1000 - n%1000 << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	// int T=0;
	// cin >> T;

	// while(T--)
		solve();
	return 0;
}

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

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

Measured memory_bytes: 4048
<?php

while (true) {
	$input = trim(fgets(STDIN));
	$input = explode(" ", $input);
	foreach ($input as $value) {
		$args[] = $value;
		if (count($args) >= 1) {
			break;
		}
	}
	if (count($args) >= 1) {
		break;
	}
}

$rate = $args[0];

if ($rate >= 2800) {
	echo "AGC";
}elseif ($rate >= 1200) {
	echo "ARC";
}else{
	echo "ABC";
}

Measured memory_bytes: 4856
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	
	char b;
	cin >> b;

	if (b == 'A')
	{
		cout << "T" << endl;
	}
	else if (b == 'C')
	{
		cout << "G" << endl;
	}
	else if (b == 'T')
	{
		cout << "A" << endl;
	}
	else if (b = 'G')
	{
		cout << "C" << endl;
	}
	

}

Measured memory_bytes: 256
N = int(input())
gcdlst = []
for i in range(1, int(N ** 0.5) + 1):
    if N % i == 0:
        gcdlst.append(i)
        if i != N // i:
            gcdlst.append(N // i)
gcdlst.sort()
tmplen = len(gcdlst)
if tmplen % 2 == 0:
    tmplen = tmplen // 2
    ans = gcdlst[tmplen] + gcdlst[tmplen - 1] - 2
else:
    tmplen = tmplen // 2
    ans = (2 * gcdlst[tmplen]) - 2
print(ans)


Measured memory_bytes: 3296
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    int ary[10];
    for (int i = 0; i < 10; i++) {
        int t;
        cin >> t;
        ary[i] = t;
    }
    sort(ary, ary+10, greater<int>());
    for (int i = 0; i < 3; i++) {
        cout << ary[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


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

  rep2(i, a, b+1) {
    if (i % k == 0) {
      cout << "OK" << "\n";
      return 0;
    }
  }
  cout << "NG" << "\n";
  return 0;
}


Measured memory_bytes: 3640
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n,m;
 
   cin >> n >> m;
  
   if(n>m){
     
     for(int i=0;i<n;i++){
       
       if(i!=n-1){
         cout << m;
       }else{
         cout << m << endl;
       }

     }
   }else{
      for(int i=0;i<m;i++){
       if(i!=m-1){
       cout << n;
       }else{
         cout << n << endl;
       }

     }
     
   }
   
   
  return 0;
}

Measured memory_bytes: 256
import bisect
import sys
import math
import itertools
sys.setrecursionlimit(10000)

INF = float('inf')

# input macro
def i():
    return int(raw_input())
def ii():
    return map(int,raw_input().split(" "))
def s():
    return raw_input()
def ss():
    return raw_input().split(" ")
def slist():
    return list(raw_input())
#

def join(s):
    return ''.join(s)

#iterate macro
def piter(n,m):
    return itertools.permutations(n,m)
def citer(n,m):
    return itertools.combinations(n,m)

#modulo macro
def modc(a,b,m):
    c = 1
    for i in xrange(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def gcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = gcd(a, m)
    return inv % m

#bisect macro
def index(a, x):
    #Locate the leftmost value exactly equal to x
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    return -1

#memoize macro
def memoize(f):
    cache = {}
    def helper(*args):
        if args not in cache:
            cache[(args)] = f(*args)
        return cache[args]
    return helper

@memoize
def nck(a,b,m):
    b = min([a-b,b])
    if (b>a or b<0 or a<0):
        return 0
    elif a == 0:
        return 1
    return (nck(a-1,b-1,m)+nck(a-1,b,m)) % m

nh=zip([1,0,-1,0],[0,1,0,-1])

###########

n=i()
a=ii()
cnt=0
for j in range(n):
    if a[a[j]-1]-1==j:
        cnt+=1
print cnt/2


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

#define MAX_N 100

int  h[MAX_N];

int main() {
  int n;

  std::cin >> n;
  for(int i = 0; i < n; ++i) {
    std::cin >> h[i];
  }

  int ans = 0;
  while(*std::max_element(h, h + n) > 0) {
    int i = 0;
    while(i < n) {
      if(h[i] == 0) ++i;
      else {
        ++ans;
        while(i < n && h[i] > 0) {
          --h[i];
          ++i;
        }
      }
    }
  }

  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.ArrayDeque
import kotlin.math.max

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()
    var ans = 0L
    var last = aList.first()
    for (a in aList.drop(0)) {
        if (a < last) {
            ans += last - a
        }

        last = max(a, last)
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 75304
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)



Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

N = int(input())
c = [0] * (2 * N)
a = [0] * (2 * N)
for i in range(2 * N):
    c[i], a[i] = input().split()
    a[i] = int(a[i]) - 1

idx = [[0] * 2 for _ in range(N)]
for i in range(2 * N):
    idx[a[i]][c[i] == 'W'] = i

costB = [[0] * (N + 1) for _ in range(N)]
for i in range(N):
    j = idx[i][0]
    cnt = 0
    for k in range(i):
        if j < idx[k][0]:
            cnt += 1
    costB[i][0] = j + cnt - i
    cnt2 = 0
    for k in range(1, N + 1):
        if j < idx[k - 1][1]:
            cnt2 += 1
        costB[i][k] = j + cnt + cnt2 - (i + k)

costW = [[0] * (N + 1) for _ in range(N)]
for i in range(N):
    j = idx[i][1]
    cnt = 0
    for k in range(i):
        if j < idx[k][1]:
            cnt += 1
    costW[i][0] = j + cnt - i
    cnt2 = 0
    for k in range(1, N + 1):
        if j < idx[k - 1][0]:
            cnt2 += 1
        costW[i][k] = j + cnt + cnt2 - (i + k)

dp = [[10**18] * (N + 1) for _ in range(2 * N + 1)]
dp[0][0] = 0
for i in range(1, 2 * N + 1):
    for j in range(max(0, i - N), min(i, N) + 1):
        dp[i][j] = dp[i-1][j] + costW[i-j-1][j]
        if j > 0:
            dp[i][j] = min(dp[i][j], dp[i-1][j-1] + costB[j-1][i-j])
print(dp[2*N][N])

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

int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}   
	cout << (*max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
        java.util.Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for(int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }
        Arrays.sort(L);
        int sum = 0;
        for(int i = 0; i < N-1; i++) {
            sum += L[i];
        }
        if(L[N-1] < sum) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

typedef map<int, pair<int, long long> > mipill;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		mipill data;
		rep(i, n){
			int a, b, c;
			scanf("%d%d%d", &a, &b, &c);
			long long sum = ((long long)b) * c;
			if(data.count(a))
				data[a].second += sum;
			else
				data[a] = make_pair(data.size(), sum);
		}

		vector<pii> v;
		for(mipill::iterator itr = data.begin(); itr != data.end(); ++itr){
			if(itr->second.second >= 1000000ll)
				v.push_back(pii(itr->second.first, itr->first));
		}

		sort(v.begin(), v.end());
		rep(i, v.size()){
			printf("%d\n", v[i].second);
		}
		if(v.empty())
			puts("NA");
	}
	return 0;
}

Measured memory_bytes: 0
n = int(input())
ListA = [int(val) for val in input().split()]
ListB = [int(val) for val in input().split()]
ListC = [int(val) for val in input().split()]
prevA = -1
point = 0
for val in ListA:
	point += ListB[val - 1]
	if (val == prevA + 1):
		point += ListC[prevA - 1]
	prevA = val
print(point)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP2(i,n,s) for(int i=(int)s;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int x = min(b,d) - max(a,c);
    if(x<0) cout << 0 << endl;
    else cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int k;
	cin >> k;

	int a, b;
	cin >> a >> b;

	for(int i = a; i <= b; i++){
		if(i % k == 0){
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;
}


Measured memory_bytes: 3592
import java.util.Scanner;
import java.lang.Math;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),
            m = sc.nextInt();
        int A = 0;
        for(int i=0;i<m;i++){
            A = A + sc.nextInt();
        }
        if(A <= n){
            System.out.print(n-A);
        }else{
            System.out.print(-1);
        }
        
    }
}

Measured memory_bytes: 46364
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll x; cin >> x;
    cout << x / 500 * 1000 + (x % 500 / 5 * 5) << endl;
}

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

int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	vector<int> C(n);
	vector<vector<int>> A(n,vector<int>(m));
	for(int i=0;i<n;i++)
	{
		cin>>C[i];
		for(int j=0;j<m;j++) cin>>A[i][j];
	}
	int ans=1e7;
	for(int mask=0;mask<1<<n;mask++)
	{
		vector<int> L(m);
		int how=0;
		for(int bit=0;bit<n;bit++)
		{
			if((mask>>bit)&1)
			{
				how+=C[bit];
				for(int i=0;i<m;i++) L[i]+=A[bit][i];
			}
		}
		bool ok=true;
		for(int i=0;i<m;i++) if(L[i]<x) ok=false;

		if(ok) ans=min(ans,how);
	}
	if(ans==1e7) cout<<-1<<endl;
	else cout<<ans<<endl;
	
}

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

int main() {
  ios::sync_with_stdio(false);
  
  int N, Q;
  cin >> N >> Q;

  vector<char> A(N);
  for (int i = 0; i < N; i++) {
    char C;
    cin >> C;
    A.at(i) = C;
  }

  vector<int> B(N);
  for (int i = 1; i < N; i++) {
    if (A.at(i - 1) == 'A' && A.at(i) == 'C') B.at(i)++;
    B.at(i) += B.at(i - 1);
  }

  for (int i = 0; i < Q; i++) {
    int L, R;
    cin >> L >> R;
    cout << B.at(R - 1) - B.at(L - 1) << endl;
  }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
#define pcnt(b) __builtin_popcount(b)
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int,int>>
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ll INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,x,y;
    cin>>n;
    int red[210][210]={},blue[210][210]={};
    rep(i,0,n){
        cin>>x>>y;
        red[x][y]=1;
    }
    rep(i,0,n){
        cin>>x>>y;
        blue[x][y]=1;
    }
    int ans = 0;
    n*=2;
    rep(i,0,n){
        rep(j,0,n){
            if(!blue[i][j]){continue;}
            else{
                int mx=-1,my=-1;
                rep(k,0,i){
                    rep(l,0,j){
                        if(red[k][l]&&(l>my||my==-1)){
                            mx = k;my = l;
                        }
                    }
                }
                if(mx!=-1&&my!=-1){blue[i][j]=0;red[mx][my]=0;ans++;}
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 896
N = int(input())
D, X = [int(a) for a in input().split()]
A = []
for _ in range(N):
    A.append(int(input()))
choco = [0 for _ in range(D)]

for i in range(N):
    day = 1
    j = 0
    while day <= D:
        choco[day-1] += 1
        j += 1
        day = A[i] * j + 1

ans  = sum(choco) + X
print(ans)

Measured memory_bytes: 9184
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string deck;
	while (true)
	{
		cin >> deck;
		if (deck == "-")
			break;
		int shuffleTime;
		cin >> shuffleTime;
		for (int i = 0; i < shuffleTime; i++)
		{
			int shuffleNum;
			cin >> shuffleNum;
			string tmp = deck.substr(0, shuffleNum);
			deck.append(tmp);
			deck.erase(0, shuffleNum);
		}
		cout << deck << endl;
	}
}


Measured memory_bytes: 3044
#include <algorithm>
#include <iostream>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int INF = INT_MAX / 2;

vector<int> P;

int solve(const int N) {
    int m = INF;
    int count = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= m) {
            count++;
            m = P[i];
        }
    }
    return count;
}

int main(void) {
    int N;
    cin >> N;

    P.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }

    cout << solve(N) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std; 
#define int long long
int INF = 1e9+7;
signed main() {
    int D,G;
    cin >> D >> G;
    vector<int>P(D);
    vector<int>C(D);
    for(int i = 0; i < D; i++) {
        cin >> P[i] >> C[i];
    }
    int ans = INF;
    for(int bit = 0; bit < (1 << D); bit++) {
        int cnt = 0; 
        int cnt2 = 0;
        int MAX = 0;
        for(int i = 0; i < D; i++) {
            if(1 & (bit >> i)) {
                cnt+=(i+1)*100*P[i]+C[i];
                cnt2+=P[i];
            }
            else {
                MAX = i+1;
            }
        }
        if(cnt < G) {
            int X = (G-cnt+MAX*100-1)/(MAX*100);
            if(X >= P[MAX-1]) {
                continue;
            }
            cnt2+=X;
        }
        ans = min(ans,cnt2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
	n = 0 #乗客数
	c = 0 #バスの定員
	k = 0 #猶予
	arraival_time = [] 

	n,c,k = input().split(' ')
	n = int(n)
	c = int(c)
	k = int(k)

	for i in range(n):
		tmp = int(input())
		arraival_time.append(tmp)

	arraival_time.sort()
	counting_bus = 0

	while(1):
		passenger = []
		times = 0
		rslt = making_bus(c, k, arraival_time, passenger, times) 
		if rslt == 0:
			break
		elif rslt == 1:
			counting_bus += 1

	print(counting_bus)
		
		

def making_bus(c, k, arraival_time, passenger,times):
	if arraival_time:
		if not passenger:
			passenger.append(arraival_time.pop(0))
			times += 1
			#recursion
			making_bus(c, k, arraival_time, passenger, times)
			return 1
	
		elif (len(passenger) < c):
			if (arraival_time[0]-passenger[0] <= k):
				passenger.append(arraival_time.pop(0))
				times += 1
				#recursion
				making_bus(c, k, arraival_time, passenger, times)
				return 1
			else:
				return 1
		else:
			return 1
				
	elif times == 0:
		return 0
	elif times > 0:
		return 1







if __name__ == '__main__':
	main()


Measured memory_bytes: 7440
import sys
s=input()
n=len(s)
s_pre = s[:(n-1)//2]
s_epi = s[(n+1)//2:]
if s != s[::-1]:
    print('No')
    sys.exit()
if s_pre != s_pre[::-1]:
    print('No')
    sys.exit()
if s_epi != s_epi[::-1]:
    print('No')
    sys.exit()
print('Yes')


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

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

struct Point {
  double x, y;
};
typedef Point Vector;
double dot(Vector a, Vector b) {
  return a.x*b.x + a.y*b.y;
}
double cross(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}

int main() {
  ll n;
  cin >> n;
  rep(i, n) {
    Vector a, b;
    double x, y;
    cin >> x >> y;
    a.x = x; a.y = y;
    cin >> x >> y;
    a.x -= x; a.y -= y;
    cin >> x >> y;
    b.x = x; b.y = y;
    cin >> x >> y;
    b.x -= x; b.y -= y;
    if (dot(a, b) == 0) {
      cout << 1 << endl;
    } else if (cross(a, b) == 0) {
      cout << 2 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackControler readDataArr = new StackControler(in.readLine()
				.split(" "));
		System.out.println(readDataArr.calcData());
	}
}

class Stack {
	private int[] stack;
	private static int pointer = 0, popData, remover = 0;

	Stack(int[] stack) {
		this.stack = stack;
	}

	public void push(int data) {
		stack[pointer] = data;
		pointer++;
	}

	public int pop() {
		pointer--;
		popData = stack[pointer];
		stack[pointer] = remover;// pop????????????data?????????
		return popData;
	}

}

class StackControler {
	private Stack stack;
	private String[] readData;
	private int operand2, operand1, result, strToIntData;

	StackControler(String[] readData) {
		this.readData = readData;
	}

	public int calcData() {
		String tempStrData;
		stack = new Stack(new int[readData.length / 2 + 1]);
		for (int i = 0; i < readData.length; i++) {
			tempStrData = readData[i];

			if (tempStrData.equals("+")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 + operand1;
				stack.push(result);
			} else if (tempStrData.equals("-")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 - operand1;
				stack.push(result);
			} else if (tempStrData.equals("*")) {
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 * operand1;
				stack.push(result);
			} else {
				strToIntData = Integer.parseInt(readData[i]);
				stack.push(strToIntData);
			}
		}
		result = stack.pop();
		return result;
	}
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

ll N;
ll A, B;
ll res;

void init()
{
	cin >> N >> A >> B;
}



void solve()
{
	ll x, y;
	cin >> y;
	rep(i, N-1) {
		x = y;
		cin >> y;
		res += min(A*(y-x), B);
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  long long int g[5][4001]={0,0};
  g[0][0]=1;
  for(int i=0;i<4;i++){
    for(int j=0;j<=4000;j++){
      if(g[i][j]){
    for(int k=0;k<=1000;k++) g[i+1][j+k]+=g[i][j];
      }
    }
  }
  while(cin>>n){
    cout<<g[4][n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1320
N = int(input())
l = [int(input()) for _ in range(N)]

dp1 = [0]*(N+1)
dp2 = [0]*(N+2)

for i in range(1, N+1):
    dp1[i] = max(dp1[i-1], l[i-1])

for i in range(1, N+1)[::-1]:
    dp2[i] = max(dp2[i+1], l[i-1])

for i in range(1, N+1):
    print(max(dp1[i-1], dp2[i+1]))

Measured memory_bytes: 15636
N, W = gets.split.map(&:to_i)

w1 = nil
wv = Hash.new { |h, k| h[k] = [] }.tap do |y|
  N.times do |i|
    w, v = gets.split.map(&:to_i)
    y[w] << v
    w1 = w if i == 0
  end
  y[w1] = y[w1].sort { |a, b| b <=> a }
  y[w1+1] = y[w1+1].sort { |a, b| b <=> a }
  y[w1+2] = y[w1+2].sort { |a, b| b <=> a }
  y[w1+3] = y[w1+3].sort { |a, b| b <=> a }
end

max = 0
(0..wv[w1].size).each do |a|
  next if w1 * a > W
  (0..wv[w1+1].size).each do |b|
    next if w1 * a + (w1+1) * b > W
    (0..wv[w1+2].size).each do |c|
      next if w1 * a + (w1+1) * b + (w1+2) * c > W
      (0..wv[w1+3].size).each do |d|
        next if w1 * a + (w1+1) * b + (w1+2) * c + (w1+3) * d > W
        sum = wv[w1].take(a).inject(0, &:+) \
          + wv[w1+1].take(b).inject(0, &:+) \
          + wv[w1+2].take(c).inject(0, &:+) \
          + wv[w1+3].take(d).inject(0, &:+)
        max = sum if max < sum
      end
    end
  end
end
puts max

Measured memory_bytes: 1788
class Dice:
    def __init__(self):
        self.faces=[]

    def rotate(self, direction):
        tmp = self.faces.copy()

        if direction =="N":
            self.faces[5-1] = tmp[1-1]
            self.faces[1-1] = tmp[2-1]
            self.faces[2-1] = tmp[6-1]
            self.faces[6-1] = tmp[5-1]
        if direction =="S":
            self.faces[5-1] = tmp[6-1]
            self.faces[1-1] = tmp[5-1]
            self.faces[2-1] = tmp[1-1]
            self.faces[6-1] = tmp[2-1]
        if direction =="W":
            self.faces[4-1] = tmp[1-1]
            self.faces[1-1] = tmp[3-1]
            self.faces[3-1] = tmp[6-1]
            self.faces[6-1] = tmp[4-1]
        if direction =="E":
            self.faces[3-1] = tmp[1-1]
            self.faces[1-1] = tmp[4-1]
            self.faces[4-1] = tmp[6-1]
            self.faces[6-1] = tmp[3-1]
        return 0

    def spin(self):
        self.faces[4-1], self.faces[2-1],self.faces[5-1],self.faces[3-1] =\
        self.faces[2-1], self.faces[3-1],self.faces[4-1],self.faces[5-1]

        return 0

d1 = Dice()
d2 = Dice()
d1.faces=[int(x) for x in input().split(" ")]
d2.faces=[int(x) for x in input().split(" ")]
up,front = d1.faces[0], d1.faces[1]

res = "No"
#set up side
for _ in range(3):
    for _ in range(4):
        for ___ in range(4):
            #print("d1: {}".format(d1.faces))
            #print("d2: {}".format(d2.faces))
            if d1.faces == d2.faces:
                res = "Yes"
                break
            d2.spin()
        d2.rotate("W")
    d2.rotate("N")

print(res)

Measured memory_bytes: 7832
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main() {
	char s[11];
	int i,j,cnt_AB = 0, cnt_A = 0, cnt_B = 0,cnt2=0,n;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s", s);
		for (j = 0; s[j + 1] != '\0'; j++) {
			if (s[j] == 'A'&&s[j + 1] == 'B') {
				cnt_AB++;
				j++;
				if (s[j + 1] == '\0')
					break;
			}
		}
		if (s[0] == 'B')
			cnt_B++;
		if (s[j] == 'A')
			cnt_A++;
		if (s[0] == 'B'&&s[j] == 'A')
			cnt2++;
	}
	if (cnt_A > cnt_B)
		cnt_AB += cnt_B;
	else
		cnt_AB += cnt_A;
	if (cnt_A == cnt2 && cnt_B == cnt2 && cnt2)
		cnt_AB--;
	printf("%d\n", cnt_AB);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;

	int a = 1;
	while (n > 0) {
		if (a * 2 <= a + k) {
			a *= 2;
		}
		else {
			a += k;
		}
		n--;
	}

	dunk(a);

	return 0;
}

Measured memory_bytes: 256
/*input
3
1 2 3
*/

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

// from atcoder live
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
 
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    cin >> n;
    vector<mint> a(n), s(n+1);
    rep(i, n) {
        int t;
        cin >> t;
        a[i] = t;
        s[i+1] = s[i]+t;
    }
    mint ans = 0;
    rep(i, n-1) {
        ans += s[i+1]*a[i+1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 6380
n, m = map(int, input().split())

r = [False] * n
r[0] = True
l = [1] * n

for _ in range(m):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    l[x] -= 1
    l[y] += 1
    r[y] = r[x] | r[y]
    if not l[x]:
        r[x] = False

c = 0
for i in range(n):
    if r[i] == True and l[i] > 0:
        c += 1

print(c)


Measured memory_bytes: 4596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
  int H, W;
  string C[110];

  cin >> H >> W;

  for(int i = 0; i < H; i++) cin >> C[i];

  for(int i = 0; i < 2 * H; i++) cout << C[i/2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    priority_queue<double> pq;
    int n,m;
    cin >> n >> m;
    double price;
    rep(i,n){
        cin >> price;
        pq.push(price);
    }
    rep(i,m){
        price = pq.top();
        pq.pop();
        price /= 2;
        pq.push(price);
    }

    ll ans = 0;
    ll price2;
    rep(i,n){
        price2 = pq.top();
        pq.pop();
        //cout << i << " " << price2 << endl;
        ans += price2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define int long long
using namespace std ; 

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ; 
	
	int cnt = 0 ,ans = 0  ;              
	string s ; 
	cin >> s; 
	for(int i = 0 ; i < 3 ;++i)
	{
		if(s[i] == 'R')
			cnt++ ; 
		else 
		{
			cnt = 0 ;  
		}
		ans = max(cnt , ans ) ; 
	}
	cout << ans ;

}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>

#define INF 10000000
using namespace std;

int H, W, N;
char M[1000][1000];
int G[10][10];

class Point {
public:
  int x;
  int y;
  int cost;
  Point(int x, int y, int cost = 0) : x(x), y(y), cost(cost) {}
};

void makedist(Point sp) {
  bool visited[1000][1000];
  const int dx[4] = {1,0,-1,0};
  const int dy[4] = {0,1,0,-1};
  queue<Point> que;
  int s;

  if(M[sp.y][sp.x] == 'S') s = 0;
  else               s = M[sp.y][sp.x]-'0';

  fill(visited[0], visited[1000], false);
  visited[sp.y][sp.x] = true;
  que.push(sp);

  while(!que.empty()) {
    Point p = que.front(); que.pop();

    if(M[p.y][p.x] != '.') {
      int g;
      if(M[p.y][p.x] == 'S') g = 0;
      else                   g = M[p.y][p.x]-'0';
      G[s][g] = G[g][s] = p.cost;
    }

    for(int i = 0; i < 4; i++) {
      int nx = p.x + dx[i];
      int ny = p.y + dy[i];
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      if(visited[ny][nx]) continue;
      if(M[ny][nx] == 'X') continue;
      visited[ny][nx] = true;
      que.push(Point(nx, ny, p.cost+1));
    }
  }
}

int make() {
  fill(G[0], G[10], INF);
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(M[i][j] != '.' && M[i][j] != 'X') {
	makedist(Point(j, i, 0));
      }
    }
  }
}

class State {
public:
  int p;
  int hp;
  int cost;
  bool got[10];

  bool operator <(const State &s) const {
    if(cost != s.cost) return cost > s.cost;
    for(int i = 1; i <= N; i++) {
      if(!got[i] && s.got[i]) return true;
      if(got[i] && !s.got[i]) return false;
    }
    if(hp != s.hp) return hp > s.hp;
    return p < s.p;
  }

  bool get(int i) {
    if(i != 0 && hp >= i && !got[i]) {
      got[i] = true;
      hp++;
      return true;
    } else {
      return false;
    }
  }
};

class State2 {
public:
  int p;
  int hp;
  int got[10];

  State2(State s) {
    p = s.p;
    hp = s.hp;
    for(int i = 1; i <= N; i++) got[i] = s.got[i];
  }

  bool operator <(const State2 &s) const {
    for(int i = 1; i <= N; i++) {
      if(!got[i] && s.got[i]) return true;
      if(got[i] && !s.got[i]) return false;
    }
    if(hp != s.hp) return hp < s.hp;
    return p < s.p;
  }
};

int solve() {
  priority_queue<State> que;
  set<State2> vis;

  State s;

  make();

  s.p = 0;
  s.hp = 1;
  s.cost = 0;
  for(int i = 1; i <= N; i++) s.got[i] = false;

  que.push(s);
  vis.insert(State2(s));

  while(!que.empty()) {
    s = que.top(); que.pop();
    if(s.hp == N+1) return s.cost;

    for(int i = 0; i <= N; i++) {
      if(i == s.p) continue;
      if(G[s.p][i] == INF) continue;
      State ns = s;
      ns.p = i;
      ns.cost += G[s.p][i];
      if(vis.find(State2(ns)) == vis.end()) {
	vis.insert(State2(ns));
	que.push(ns);
      }
      if(ns.get(i)) {
	if(vis.find(State2(ns)) == vis.end()) {
	  vis.insert(State2(ns));
	  que.push(ns);
	}
      }
    }
  }
  return 0;
}
main() {
  cin >> H >> W >> N;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> M[i][j];
    }
  }
  cout << solve() << endl;
}

Measured memory_bytes: 2832
#include<stdio.h>

int main()
{
    int a,b,c,d,e;

    scanf("%d %d %d %d %d", &a, &b, &c, &d, &e);

    if(c + e <= a && e <= c && d + e <= b && e <= d)
	printf("Yes\n");
    else
	printf("No\n");

    return 0;
}



Measured memory_bytes: 2144
#include<iostream> 
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#define ll long long
const int N=0x3f3f3f3f;
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
	int n;
	cin>>n;
	cout<<a[n-1]<<endl;
	return 0;
} 

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

int main(void) {
    int N; cin >> N;
    string c; cin >> c;
    int red=0,white=0;
    int ans_min=300000;
    int count_W=0,count_R=0;
    for(int i=0; i<N; i++) {
        if(c[i] == 'R') red++;
        else if(c[i] == 'W') white++;
    }

    if(N==red || N==white) {
        cout << 0 << endl;
        return 0;
    }

    for(int i=0;i<N-1;i++) {
        int ans;
        if(c[i] == 'R') count_R++;
        else if(c[i] == 'W') count_W++;
        int count = red - count_R;
        if(count_W<=count) ans = count;
        else ans = count_W;
        if(ans_min>ans) ans_min = ans;
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 3728
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    res = 0
    if 2 * n <= m:
        res += n
        m -= n * 2
        res += m // 4
    else:
        res += m // 2

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] in = new int[N];

		int diff =0;
		for(int i =0;i<N;i++) {
			in[i] = scan.nextInt();
			if (i+1 == in[i]) {
				continue;
			}
			diff++;
		}
		if(diff ==0 || diff ==2) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		scan.close();
	}

}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,a[2005],in[2005];
bool vis[2005];
priority_queue<int> pq;
vector<int> g[2005],nei[2005];
void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<g[x].size();i++)
		if(!vis[g[x][i]])
		{
			in[g[x][i]]++;
			nei[x].push_back(g[x][i]);
			dfs(g[x][i]);
		}
}
void topo()
{
	for(int i=1;i<=n;i++)
		if(!in[i])
			pq.push(i);
	while(!pq.empty())
	{
		int now=pq.top();
		pq.pop();
		cout<<a[now]<<' ';
		for(int i=0;i<nei[now].size();i++) pq.push(nei[now][i]);
	}
	cout<<endl;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])!=1)
			{
				g[i].push_back(j);
				g[j].push_back(i);
			}
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i);
	topo();
	return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == ',')
        { s[i] = ' '; }
    }
        cout << s;

        return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    if n%10 == 9 or n//10 == 9:
        return 'Yes'

    return 'No'

print(main())





Measured memory_bytes: 7620