akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int n, k;
        string s;
        cin >> n >> k >> s;
        for(int i=0;i<n;i++)
        {
            if(i==k-1)
                cout << char(s[i] -'A' + 'a');
            else
            cout << s[i];
        }
    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

using namespace std;

int main () {
	long long n, t;
	scanf("%lld %lld", &n, &t);
	long long arr[n];
	for (int i = 0; i < n; i++)
		scanf("%lld", &arr[i]);
	long long ans = 0, limit = -1;
	for (int i = 0; i < n; i++) {
		ans += t;
		if (arr[i] <= limit)
			ans -= (limit - arr[i] + 1); 
		limit = arr[i] + t - 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl 
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end()) 
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    ll a, b, x, ans = 0;
    cin >> a >> b >> x;

    ans = (b / x) - (a / x);
    ans += (a % x == 0);
    cout << ans << endl;
}


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


int main(){
    ll N, ans = 0;
    cin >> N;
    vector<ll> vec(3 * N,0);
    for(int i = 0; i < 3 * N; i++) cin >> vec[i];
    sort(vec.begin(),vec.end() ,greater<ll>());
    for(int i = 0; i < 2 * N; i += 2){
        vec[i] = 0;
        vec[3 * N - i];
        ans += vec[i + 1];
        vec[i + 1] = 0;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int H, W;
std::vector<std::vector<int>>c, A;
int ans;

void warshall_floyd(int V)
{
	for (int k = 0; k < V; ++k)
	{
		for (int i = 0; i < V; ++i)
		{
			for (int j = 0; j < V; ++j)
			{
				c[i][j] = std::min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}
}


int main()
{
	c.resize(10);
	rep(i, c.size()) { c[i].resize(10); }
	in >> H >> W;
	rep(i, 10) { rep(j, 10) { in >> c[i][j]; } }
	A.resize(H);
	rep(i, A.size()) { A[i].resize(W); }
	rep(i, H) { rep(j, W) { in >> A[i][j]; } }

	warshall_floyd(10);
	for (auto i : A)
	{
		for (auto j : i)
		{
			if (j == -1) { continue; }
			ans += c[j][1];
		}
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 384
/**    epsileer 01 September 2019  17:45:10  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST LL t = 1; while(t--) solve()

void solve(){
    LL n; cin>>n;
    vector<LL> a(n);
    for(LL i=0;i<n;i++)cin>>a[i];
    LL ans = 0;
    LL temp = 0;
    for(LL i=n-2;i>=0;i--){
        if(a[i] >= a[i+1]){
            temp++;
            ans = max(temp, ans);
        }else{
            temp = 0;
        }
    }
    cout<<ans;
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		int n = sc.nextInt();
		int answer = 0;
		for(int red = 0;red <=n;red += r) {
			for(int green = 0;green <=n -red;green+=g) {
				if((n-red-green) % b ==0) {
					answer++;
				}
			}
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21716
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int K = scan.nextInt();
    int sum = 0;
    Integer[] p = new Integer[N];
    for (int i = 0; i < N; i++) {
      p[i] = scan.nextInt();
    }
    Arrays.sort(p);
    for (int i = 0; i < K; i++) {
      sum += p[i];
    }
    System.out.println(sum);
  }
}



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

int main()
{
    std::string word;

    std::cin>> word;
    std::vector< int > people_count( word.size(), 0 );
    int count = 0;
    int last = 0;

    for( int i = 0; i < word.size(); i++ )
    {
        if( word[last] != word[i] )
        {
            if( word[last] == 'R' )
            {
                people_count[i-1] += count / 2 + ( count % 2 );
                people_count[i] += count / 2;
            }
            else
            {
                people_count[last] += count / 2 + ( count % 2 );
                people_count[last-1] += count / 2;
            }

            last = i;
            count = 0;
        }
        
        if( i == word.size() - 1 )
        {
            count += 1;
            people_count[last] += count / 2 + ( count % 2 );
            people_count[last-1] += count / 2;
        }

        count += 1;
    }

    for( int i = 0; i < people_count.size(); i++ )
    {
        std::cout<< people_count[i] <<" ";
    }
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class _C
{
	void _()
	{
		var _n = _Ns();

		Array.Sort(_n);
		if (_n[0] == 5)
		{
			if (_n[1] == 5)
			{
				if (_n[2] == 7)
				{
					Console.WriteLine("YES");
					return;
				}
			}
		}
		Console.WriteLine("NO");			

	}

	static void Main(string[] args)
  {
    new _C()._();
  }

  #region

  string _S()
  {
    return Console.ReadLine();
  }

  string[] _Ss()
  {
    return Console.ReadLine().Split();
  }

  int[] _N(int n)
  {
    var x = new int[n];
    for (var i = 0; i < n; i++)
    {
      x[i] = int.Parse(Console.ReadLine());
    }
    return x;
  }

  int[] _Ns()
  {
    var ss = Console.ReadLine().Split();

    var x = new int[ss.Length];
    for (var i = 0; i < ss.Length; i++)
      x[i] = int.Parse(ss[i]);

    return x;
  }
  #endregion
}

Measured memory_bytes: 2648
import java.util.Scanner;


public class Main{
	static int[] depth;
	static int[] leftChild;
	static int[] rightChild;
	static int[] parent;
	static String[] type;
	static int[] height;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int cnt = new Integer(s.nextLine()).intValue();
		parent = new int[cnt];
		leftChild = new int[cnt];
		rightChild = new int[cnt];
		int[] sibling = new int[cnt];
		int[] degrees = new int[cnt];
		type = new String[cnt];
		depth = new int[cnt];
		height = new int[cnt];
		for(int a=0 ; a<cnt ; a++) {
			parent[a] = -1;
			leftChild[a] = -1;
			rightChild[a] = -1;
			sibling[a] = -1;
			degrees[a] = 0;
			depth[a] = 0;
			type[a] = "root";
			height[a] = 0;
		}
		int root = -1;
		for(int i=0 ; i<cnt ; i++) {
			String[] tmp = s.nextLine().split(" ");
			int degree = 0;
			leftChild[new Integer(tmp[0]).intValue()] = new Integer(tmp[1]).intValue();
			rightChild[new Integer(tmp[0]).intValue()] = new Integer(tmp[2]).intValue();
			if(new Integer(tmp[1]).intValue()!=-1){
				parent[new Integer(tmp[1]).intValue()] = new Integer(tmp[0]).intValue();
				degree++;
			}
			if(new Integer(tmp[2]).intValue()!=-1) {
				parent[new Integer(tmp[2]).intValue()] = new Integer(tmp[0]).intValue();
				degree++;
			}
			degrees[new Integer(tmp[0]).intValue()] = degree;
			if(new Integer(tmp[1]).intValue()!=-1 && new Integer(tmp[2]).intValue()!=-1) {
				sibling[new Integer(tmp[1]).intValue()] = new Integer(tmp[2]).intValue();
				sibling[new Integer(tmp[2]).intValue()] = new Integer(tmp[1]).intValue();
			}

			for(int j=0 ; j<parent.length ; j++) {
				if(parent[j] == -1) {
					root = j;
					break;
				}
			}
		}
		setDepth(root, 0);
		setType();
		for(int i=0 ; i<leftChild.length ; i++) {
			height[i] = setHeight(i, 0);
		}

		for(int k=0 ; k<cnt ; k++) {
			System.out.println("node " + k + ": parent = " + parent[k] + ", sibling = " + sibling[k] + ", degree = " + degrees[k] + ", depth = " + depth[k] + ", height = " + height[k] + ", "+ type[k]);
		}
	}

	public static void setDepth(int val, int d) {
		depth[val] = d;
		if(rightChild[val] != -1)
			setDepth(rightChild[val], d+1);
		if(leftChild[val] != -1)
			setDepth(leftChild[val], d+1);
	}

	public static void setType() {
		for(int i=0 ; i<leftChild.length ; i++) {
			if(parent[i] == -1) {}
			else if(leftChild[i] == -1 && rightChild[i] == -1)
				type[i] ="leaf";//leaf
			else
				type[i] = "internal node";//internal node
		}
	}

	public static int setHeight(int val, int height) {
		if(val==-1)
			return height;
		if(leftChild[val]==-1 && rightChild[val]==-1)
			return height;
		return Math.max(setHeight(leftChild[val], height+1), setHeight(rightChild[val], height+1));
	}
}

Measured memory_bytes: 17328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pbds tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define _ ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define mod 1000000007
#define deb(x) cerr << "\n" \
					<< #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
						<< #x << "=" << x << "\n" \
						<< #y << "=" << y << "\n";
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
 
int32_t main()
{
 
	int n;
	cin >> n;
 
	int sum = 0;
 
	for (int i = 1; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			for (int k = j; k <= n; k++)
			{
				int temp = __gcd(i, __gcd(j, k)) * 6;
 
				if (i == j && i == k)
					temp /= 6;
				else
				{
					if (i == j || j == k || k == i)
						temp /= 2;
				}
				sum += temp;
			}
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3636
exception Break

let _ =
  let a_cards = read_line () in
  let b_cards = read_line () in
  let c_cards = read_line () in
  let a_index = ref 0 in
  let b_index = ref 0 in
  let c_index = ref 0 in
  let next = ref 'a' in
  try
    while true do
      let cards =
        match !next with
        | 'a' -> a_cards
        | 'b' -> b_cards
        | _   -> c_cards in
      let index =
        match !next with
        | 'a' -> a_index
        | 'b' -> b_index
        | _   -> c_index in
      if !index >= String.length cards
      then (print_char (Char.uppercase !next);
            print_newline ();
            raise Break
           )
      else (next := String.get cards !index;
            index := !index + 1
           )
    done
  with Break -> ()


Measured memory_bytes: 384
/* ABC174 B */

#include<stdio.h>

int main(void){
    int n, i, count=0;
    long long d, x, y;
    scanf("%d %lld", &n, &d);
    for(i=0; i<n; i++){
        scanf("%lld %lld", &x, &y);
        if(x*x+y*y <= d*d){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}


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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n);
	for (int i=0; i<n; i++) cin>>a[i];
	sort(a.rbegin(),a.rend());
	int ret=0;
	for (int i=0; i<n; i++)
		if(i%2==0) ret+=a[i];
		else ret-=a[i];
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, h, w;
  cin >> n >> h >> w;
  cout << (n - h + 1) * (n - w + 1) << endl;

  return 0;
}


Measured memory_bytes: 256
x,n = map(int, input().split())

ans=0
min_ans=200
t=0

if n==0:
    print(x)
else:
    p= list(map(int,input().split()))
    for i in range(110):
        if p.count(i)==0:
            ans=abs(x-i)
            if ans<min_ans:
                min_ans=ans
                t=i
        else:
            continue

    print(t)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
//#include<iostream>
//#include<cmath>
#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int N=1e5+10;
void io(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
int main()
{
	io();
	int n,k;
	cin>>n>>k;
	if(n<k)cout<<"1"<<endl;
	else {
		cout<<n-k+1<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  int H,W; cin >> H >> W;
  vector<vector<char>> S(H,vector<char>(W));
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){cin >> S[i][j];}} // 0-indexed
  
  int dx[] = {1,1,0,-1,-1,-1,0,1};
  int dy[] = {0,1,1,1,0,-1,-1,-1};
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
     
      if( S[i][j] == '.'){
        int cnt = 0;
       for(int k = 0; k <= 7; k++){
         if(0 <= i + dx[k] && i + dx[k] < H && 0 <= j + dy[k] && j + dy[k] < W && S[i+dx[k]][j + dy[k]] == '#'){
          cnt++;}}
        S[i][j] = cnt + '0';}
    }}
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cout << S[i][j];}
    cout << endl;}
  return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
int n, q, m;
int ans[maxn], cnt[maxn], c[maxn];
struct Query
{
	int l, r, id, L;
}a[maxn];
bool cmp(const Query & i, const Query & j) { return i.L < j.L || (i.L == j.L && i.r < j.r);}
int main()
{
	scanf("%d%d", &n, &q);
	m = sqrt(q);
	for(int i = 1; i <= n; ++i) scanf("%d", &c[i]);
	for(int i = 1; i <= q; ++i) 
	{
		scanf("%d%d", &a[i].l, &a[i].r);
		a[i].L = a[i].l / m;
		a[i].id = i;
	}
	sort(a + 1, a + q + 1, cmp);
	int l = 0, r = 0, res = 0;
	for(int i = 1; i <= q; ++i)
	{
		while(r < a[i].r)
		{
			++r;
			if(!cnt[c[r]]) ++res;
			++cnt[c[r]];
		}
		while(r > a[i].r)
		{
			--cnt[c[r]];
			if(!cnt[c[r]]) --res;
			--r;
		}
		while(l < a[i].l)
		{
			--cnt[c[l]];
			if(!cnt[c[l]]) --res;
			++l;
		}
		while(l > a[i].l)
		{
			--l;
			if(!cnt[c[l]]) ++res;
			++cnt[c[l]];
		}	
		ans[a[i].id] = res;
	}
	for(int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 17424
(* Vicfred
 * https://atcoder.jp/contests/abc146/tasks/abc146_b
 * string manipulation
 * *)
let n = read_int()
let _ = String.map (fun c -> 
    Char.(chr @@ (code c - code 'A' + n) mod 26 + code 'A')) @@
    read_line() |> print_endline



Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B; cin >> A >> B;
    string S; cin >> S;
    int cnt = 0;
    for(int i = 0; i < A; i++)
    {
        if(S.at(i) < 48 || S.at(i) > 57)
        {
            cout << "No" << endl;
            cnt = 1;
            break;
        }
    }
    if(S.at(A) != '-' && cnt == 0)
    {
        cout << "No" << endl;
        cnt = 2;
    }
    if(cnt == 0)
    {
        for(int i = A + 1; i < A + B + 1; i++)
        {
            if(S.at(i) < 48 || S.at(i) > 57)
            {
                cout << "No" << endl;
                cnt = 3;
                break;
            }
        }
    }
    if(cnt == 0)
    {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
const int MOD=1e9+7;
ll asum=0,bsum=0;
ll rest=0;
int N;
ll A[100005],B[100005];
vector<pll> AB;
ll ans=0;
bool sortstand(const pll &L,const pll &R)
{
  return R.first-R.second<L.first-L.second;
}
int main(void)
{
  cin >> N;
  for (int i = 0; i < N; ++i)
    {
      cin >> A[i];
      asum+=A[i];;
    }
  for (int i = 0; i < N; ++i)
    {
      cin >> B[i];
      bsum+=B[i];
    }
  if(asum<bsum)
    {
      cout << -1 << endl;
      return 0;
    }
  for (int i = 0; i < N; ++i)
    {
      AB.push_back(pll(A[i],B[i]));
    }
  sort(AB.begin(),AB.end(),sortstand);
  reverse(AB.begin(),AB.end());
  for (int i = 0; i < N; ++i)
    {
      if(AB[i].first-AB[i].second<0)
	{
	  ans++;
	  rest+=abs(AB[i].second-AB[i].first);
	}
      else break;
    }
  reverse(AB.begin(),AB.end());
  for (int i = 0; i < N; ++i)
    {
      if(rest<=0) break;
      if(AB[i].first-AB[i].second>=0)
	{
	  if(rest>0)
	    {
	      ans++;
	      rest-=AB[i].first-AB[i].second;
	    }
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define db double
#define pi 3.14159265358979323846
#define pow pw
int pw(int a,int b){
    int ans=1;
    while(b){
    if (b%2) ans*=a;
    a*=a;
    b/=2;
    }
    return(ans);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b;
    cin>>a>>b;
    int ans=0;
    for (int i=0;i<a.length();i++) 
    if (a[i]!=b[i]) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
#ifdef umang99m
    #include "/home/umang/Desktop/folder/home/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n;
    cin>>n;
    vi a(n), b(n), c(n);
    ll d[n][3];
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    d[0][0] = a[0];
    d[0][1] = b[0];
    d[0][2] = c[0];
    repA(i,1,n-1){
        d[i][0] = max(d[i-1][1], d[i-1][2]) + a[i];
        d[i][1] = max(d[i-1][0], d[i-1][2]) + b[i];
        d[i][2] = max(d[i-1][1], d[i-1][0]) + c[i];
    }
    cout<<max(max(d[n-1][0], d[n-1][1]), d[n-1][2])<<endl;;

    timer();
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include <stdio.h>
#include<map>
//#include<set>
//#include<vector>
//#include<iomanip>
using namespace std;
long long arr[1000000];
int main(){

    long long n,m,sum=0;
    cin>>n;
    for(int i=0,x;i<n;i++){
        cin>>x;
        sum+=x;
        arr[x]++;
    }
    cin>>m;
    long long arr2[2];
    for(int i=0;i<m;i++){
        cin>>arr2[0]>>arr2[1];
        sum=sum-(arr[arr2[0]]*arr2[0])+(arr[arr2[0]]*arr2[1]);
        cout<<sum; if(i!=m-1){cout<<endl;}
        arr[arr2[1]]+=arr[arr2[0]];
        arr[arr2[0]]=0;
    }

    return 0;
}


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

int main() {
  int a, b, Q;
  cin>>a>>b>>Q;
  long long s[a+2], t[b+2];
  for (int i=0; i<a; i++) cin>>s[i+1];
  for (int i=0; i<b; i++) cin>>t[i+1];
  s[0] = -3 * 1e10;
  t[0] = -3 * 1e10;
  s[a+1] = 3 * 1e10;
  t[b+1] = 3 * 1e10;

  int slen = a + 2;
  int tlen = b + 2;

  for (int q=0; q<Q; q++) {
    long long x;
    cin>>x;

    long long ans = 1e11;
    auto it_s = lower_bound(s, s + slen, x);

    auto it_t_right_s = lower_bound(t, t + tlen, *it_s);
    ans = min(*it_t_right_s - x, ans);
    if (it_t_right_s != t) {
      ans = min(*it_s - x + (*it_s - *(--it_t_right_s)), ans);
    }

    --it_s;
    auto it_t_left_s = lower_bound(t, t + tlen, *it_s);
    ans = min(x - *it_s + (*it_t_left_s - *it_s), ans);
    if (it_t_left_s != t) {
      ans = min(x - *it_s + (*it_s - *(--it_t_left_s)), ans);
    }
    auto it_t = lower_bound(t, t + tlen, x);
    auto it_s_right_t = lower_bound(s, s + slen, *it_t);
    ans = min(*it_s_right_t - x, ans);
    if (it_s_right_t != s) {
      ans = min(*it_t - x + (*it_t - *(--it_s_right_t)), ans);
    }

    --it_t;
    auto it_s_left_t = lower_bound(s, s + slen, *it_t);
    ans = min(x - *it_t + (*it_s_left_t - *it_t), ans);
    if (it_s_left_t != s) {
      ans = min(x - *it_t + (*it_t - *(--it_s_left_t)), ans);
    }
    cout<<ans<<endl;
  }
}

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

using namespace std;
using ll=long long;

ll dp[100005][3];
ll p[100005][3];

ll N;

int main()
{
    cin >> N;
    for(int i =0;i < N;i++)
    {
        cin >> p[i][0] >> p[i][1] >> p[i][2];
    }
    dp[0][0] = p[0][0];
    dp[0][1] = p[0][1];
    dp[0][2] = p[0][2];
    for(int j = 1;j < N;j++)
    {
        dp[j][0] = max(dp[j-1][1] + p[j][0], dp[j-1][2] + p[j][0]);
        dp[j][1] = max(dp[j-1][2] + p[j][1], dp[j-1][0] + p[j][1]);
        dp[j][2] = max(dp[j-1][0] + p[j][2], dp[j-1][1] + p[j][2]);
    }

    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    bool tgl{true};
    while (true) {
        if (tgl) {
            c -= b;
            if (c <= 0) {
                cout << "Yes" << endl;
                break;
            }
            tgl=false;
        } else {
            a -= d;
            if (a <= 0) {
                cout << "No" << endl;
                break;
            }
            tgl=true;
        }
    }


    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    vector<LL> A(N);
    REP0 (i, N)
    {
        cin >> A[i];
    }

    sort(A.begin(), A.end());
    vector<LL> cum(N);

    REP0 (i, N)
    {
        cum[i] = A[i];
        if (i != 0)
            cum[i] += cum[i - 1];
    }

    int ans = N;

    RREP0(i, N - 1)
    {
        if (cum[i] * 2 < A[i + 1])
        {
            ans -= (i + 1);
            break;
        }
    }
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 1792
M=1000000007
r1,c1,r2,c2=map(int,input().split())
n=r2+c2+2
fac=[1]+[0]*n
for i in range(1,n+1):fac[i]=fac[i-1]*i%M
f=lambda r,c:fac[r+c+2]*pow(fac[c+1],M-2,M)*pow(fac[r+1],M-2,M)-1
print((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%M)

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

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var HW = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var H = HW[0];
            var W = HW[1];
            var costs = new int[10][];
            for (var i = 0; i < costs.Length; i++)
            {
                costs[i] = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            }
            costs[1][1] = 0;

            for (var k = 0; k < 10; k++)
            {
                for (var i = 0; i < 10; i++)
                {
                    for (var j = 0; j < 10; j++)
                    {
                        if (costs[i][j] > costs[i][k] + costs[k][j])
                            costs[i][j] = costs[i][k] + costs[k][j];
                    }
                }
            }

            var answer = 0;
            for (var i = 0; i < H; i++)
            {
                var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                for (var j = 0; j < A.Length; j++)
                {
                    if (A[j] >= 0) answer += costs[A[j]][1];
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 30548
import java.util.*;

public class Main {
	public static void main(String[] args){
		Prime p = new Prime();
		int n;
		Scanner sc = new Scanner(System.in);
		
		while(true){
			n = sc.nextInt();
			if(n == 0){
				break;
			}
			System.out.println(p.searchMaxQuadruplet(n));
		}
	}
}

class Prime {
	
	private final int size = 664579;
	private int[] prime;
	
	public Prime(){
		prime = new int[size];
		setPrime();
	}
	
    public void setPrime() {
        int ptr = 0;
        

        prime[ptr++] = 2;
        prime[ptr++] = 3;

        for (int n = 5; n <= 10000000; n += 2) {
            boolean flag = false;
            for (int i=1; prime[i]*prime[i]<=n; i++) {
                if (0 == n%prime[i]) {
                    flag = true;
                    break;
                }
            }
            
            if (!flag) {
                prime[ptr++] = n;
            }
        }
    }
    
    private int getIndex(int n){
    	for(int i=0; i<size; i++){
    		if(prime[i] > n){
    			return i-1;
    		}else if(prime[i] == n){
    			return i;
    		}
    	}
    	
    	return size-1;
    }
    
    public int searchMaxQuadruplet(int n){
    	int idx = getIndex(n);
    	
    	while(true){
    		if(prime[idx]-prime[idx-1] == 2){
    			if(prime[idx]-prime[idx-2] == 6){
    				if(prime[idx]-prime[idx-3] == 8){
    	    			return prime[idx];
    	    		}
        		}
    		}
    		idx --;
    	}
    	
    }
}

Measured memory_bytes: 25836
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
char s[N];

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);
    scanf("%d",&n);
    scanf("%s",s+1);

    int l=0,r=n+1;
    int ans=0;

    while(l<=r){
        do ++l;while(s[l]=='R');
        do --r;while(s[r]=='W');
        if(l<r) ans++;
    }

    printf("%d\n",ans);
    
    return 0;
}

Measured memory_bytes: 4012
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int a0 = 0, a1 = 1, b0 = 0, b1 = -1;
  int c0 = a0-b0, c1 = a0-b1, c2 = a1-b0, c3 = a1-b1;
  for(auto c: s) {
    if(c=='0')      { --a0; --a1; --b0; --b1; }
    else if(c=='1') { ++a0; ++a1; ++b0; ++b1; }
    else            { --a0; --a1; ++b0; ++b1; }
    if(a0 < 0) a0 += 2;
    if(a1 < 0) a1 += 2;
    if(b0 > 0) b0 -= 2;
    if(b1 > 0) b1 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  fin(std::min(std::min(c0, c1), std::min(c2, c3)));
  return 0;
}


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

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

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;
    using ll = long long;

    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    priority_queue<pair<ll, int>> PQ;
    rep(i, N) PQ.push(make_pair(A[i], i));

    vi discount(N, 0);

    rep(i, M) // 各割引券を1枚ずつ割り当てる
    {
        // 値段最大の商品を半額に割り引く
        ll item = PQ.top().first;
        int index = PQ.top().second;
        PQ.pop();
        discount[index]++;
        PQ.push(make_pair(item / 2, index));
    }

    ll min_cost = 0;
    rep(i, N)
    {
        if(discount[i] != 0)
            min_cost += A[i] / (ll)pow(2, discount[i]);
        else
            min_cost += A[i];
    }
    cout << min_cost << endl;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define INF 1000000007
#define MOD 998244353
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

void Main(){
	
	ll N;
	cin >> N;
	vvl v(N, vl(2));
	rep(i, N) cin >> v[i][0] >> v[i][1];
	
	vl ad(N);
	vl df(N);
	rep(i, N){
		ad[i] = v[i][0] + v[i][1];
		df[i] = v[i][0] - v[i][1];
	}
	ll ans = max(MAX(ad) - MIN(ad), MAX(df) - MIN(df));
	print(ans);
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 17200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}
int main(){
    ll X;
    cin>>X;
    ll N=100,cnt = 0;
    while(N<X){
        N = N+ N/100;
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 3632
sx,sy,tx,ty = map(int,input().split())
dx,dy = abs(sx-tx), abs(sy-ty)
fx,bx = 'RL' if sx < tx else 'LR'
fy,by = 'UD' if sy < ty else 'DU'
ans = ''
ans += fy*dy + fx*dx
ans += by*dy + bx*(dx+1)
ans += fy*(dy+1) + fx*(dx+1) + by
ans += fx + by*(dy+1) + bx*(dx+1) + fy
print(ans)

Measured memory_bytes: 3064
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {

	int a[5];
	for (size_t i = 0; i < 5; i++)
	{
		cin >> a[i];
	}
	sort(a, a + 5);
	int sum = 0;
	int mi = 0;
	for (size_t i = 0; i < 5; i++)
	{
		if (a[i] % 10 == 0) {
			sum += a[i];
		}
		else {
			sum += a[i] + 10 - (a[i] % 10);
			mi = max(10 - (a[i] % 10), mi);
		}
	}
	cout << (sum - mi) << endl;
}


int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		// 計算
		int result = 1;
		for(int i = 0; i < n; i++){
		    if(result*2 > result + k){
		        result += k;
		    }else{
		        result *= 2;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21716
a, b, c, d = map(int, input().split())
def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)
def count(x, y):
    return x // y
cd = c * d // gcd(c, d)
print(b - a + 1 - count(b, c) + count(a - 1, c) - count(b, d) + count(a - 1, d) + count(b, cd) - count(a - 1, cd))


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 998244353
//#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=3050;
//↑templete
signed main(){

    string S;
    cin>>S;
    for(int i=0;i<3;i++)
        if(S[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            var hasA = false;
            var hasB = false;
            var hasC = false;

            foreach (var item in S)
            {
                switch (item)
                {
                    case 'a':
                        hasA = true;
                        break;
                    case 'b':
                        hasB = true;
                        break;
                    case 'c':
                        hasC = true;
                        break;
                }
            }

            Console.WriteLine(hasA && hasB && hasC ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define pb push_back
#define pp pop_back()
#define mp make_pair
#define fr first
#define sc second
#define sz size()
#define smin(x,y) ((x)=min((x),(y)))
#define smax(x,y) ((x)=max((x),(y)))
#define all(x) x.begin(),x.end()
#define CS ios_base::sync_with_stdio(false);
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi; 
const int M=1e5+5;
const ll mod=1e9+7;
ll fact[M],rfact[M];
ll power(ll x,ll y){
	ll ans=1;
	ll ret=x;
	while(y){
		if(y&1ll) ans=(ans*ret)%mod;
		ret=(ret*ret)%mod;
		y>>=1;
	}
	return ans;
}
ll tar(ll k,ll n){
	if(k>n) return 0;
	return (((fact[n]*rfact[k])%mod)*rfact[n-k])%mod;
}
int ted[M];
int a[M];
int32_t main()
{
	fact[0]=rfact[0]=1;
	for(int i=1;i<M;i++) fact[i]=(fact[i-1]*(ll)(i))%mod,
		rfact[i]=power(fact[i],mod-2);
	int n; cin>>n;
	int dob;
	for(int i=0;i<=n;i++){
		cin>>a[i];
		ted[a[i]]++;
		if(ted[a[i]]==2) dob=a[i];
	}
	int p1,p2;
	for(int i=0;i<=n;i++) if(a[i]==dob){
		p1=i;
		for(int j=i+1;j<=n;j++) if(a[j]==dob) p2=j;
		break;
	}
	for(int len=1;len<=n+1;len++){
		ll kol = tar(len,n+1);
		ll man = tar(len-1,(n+1)-(p2-p1+1));
		cout << (kol + mod - man)%mod << endl;
	}
	return 0;
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int R,C,K;
  cin >> R >> C >> K;
  vector<vector<ll>> V(R,vector<ll>(C,-1));
  rep(i,K){
    int r,c,v;
    cin >> r >> c >> v;
    r--;
    c--;
    V.at(r).at(c)=v;
  }

  vector<vector<vector<ll>>> dp(R,vector<vector<ll>>(C,vector<ll>(4,0)));
  dp.at(0).at(0).at(1)=V.at(0).at(0);
  rep(i,R){
    rep(j,C){
      rep(k,4){
        if(i+1<R){
          chmax(dp.at(i+1).at(j).at(0),dp.at(i).at(j).at(k));
          chmax(dp.at(i+1).at(j).at(1),dp.at(i).at(j).at(k)+V.at(i+1).at(j));
        }
        if(j+1<C){
          chmax(dp.at(i).at(j+1).at(k),dp.at(i).at(j).at(k));
          if(k+1<4){
            chmax(dp.at(i).at(j+1).at(k+1),dp.at(i).at(j).at(k)+V.at(i).at(j+1));
          }
        }
      }
    }
  }
  ll ans=0;
  rep(i,4)  chmax(ans,dp.at(R-1).at(C-1).at(i));
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 706532
N,Q=map(int,input().split())
S=str(input())

cnt=0
cntlist=[0]
for i in range(N-1):
    if S[i:i+2]=='AC':
        cnt+=1
    cntlist.append(cnt)
for i in range(Q):
    l,r=map(int,input().split())
    print(cntlist[r-1]-cntlist[l-1])


Measured memory_bytes: 6100
//#include "stdafx.h"
#include<bits/stdc++.h> 
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
int r,g;
int main()
{
	cin>>r>>g;
	cout<<(g*2)-r<<"\n";
	return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <memory.h>
#include <sstream>
#include <iterator>
bool used[9][9];
char map[9][9];
int n, m;
void dfs (int x, int y) {
	used[x][y] = true;
	if (x + 1 < n && map[x + 1][y] == '#')
		dfs (x + 1, y);
	else if (y + 1 < m && map[x][y + 1] == '#')
		dfs(x, y + 1);
}
int main ()
{
	std::cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			std::cin >> map[i][j];
	dfs (0, 0);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (map[i][j] == '#' && used[i][j] == false)
			{
				std::cout << "Impossible";
				return 0;
			}
	std::cout << "Possible";
}

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

#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define NL -5000000

int main()
{	IOS;
	ll n,i,j,x;
	cin>>x>>n;
	ll a[n];
	bool f[201];
	MS0(f);
	FOR(i,n)
	{
		cin>>a[i];
		f[a[i]]=1;
	}
	FOR(i,101)
	{
		if(i>=x)
		{
			cout<<0;
			return 0;
		}
		if(f[x-i]==0)
		{
			cout<<(x-i);
			return 0;
		}
		if(f[x+i]==0)
		{
			cout<<(x+i);
			return 0;
		}	
	}

}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
int fatherRoad[N],fatherRail[N];
int Find(int father[],int x){
    if(x!=father[x])
        return father[x]=Find(father,father[x]);
    return x;
}
void Union(int father[],int x,int y){
    x=Find(father,x);
    y=Find(father,y);
    if(x!=y)
        father[y]=x;
}
int main() {
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    for(int i=1;i<=n;i++){
        fatherRoad[i]=i;
        fatherRail[i]=i;
    }
    for(int i=1;i<=k;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        Union(fatherRoad,x,y);
    }
    for(int i=1;i<=l;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        Union(fatherRail,x,y);
    }

    for(int i=1;i<=n;i++){
        Find(fatherRoad,i);
        Find(fatherRail,i);
    }
    map<pair<int,int>,int> mp;
    for(int i=1;i<=n;i++)
        mp[make_pair(fatherRoad[i],fatherRail[i])]++;
    for(int i=1;i<=n;i++)
        printf("%d\n",mp[make_pair(fatherRoad[i],fatherRail[i])]);
    return 0;
}


Measured memory_bytes: 16896
#include<bits/stdc++.h>
using namespace std;
 
#define     PI 				3.14159265358979
#define     mod 			1000000007
#define     ll  			long long int
#define     rep(i, a, b) 	for(ll i = a ; i < b ; i++)
#define     repn(i, a, b)   for(ll i = a ; i > b ; i--)
#define     mod1 			1000003
#define     mod2            998244353
#define     inf             2e18
#define     hi   			"hello"
#define     nl 				"\n"
#define     ws 				" "
#define     sz              size()
#define     len             length()
#define     F 				first
#define     S 				second
#define     pb				push_back
#define     MP				make_pair
#define     B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define     pll             pair<ll, ll>
#define     vll             vector<ll>
#define     vpll            vector<pll>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define     sqr(a)          ((a)*(a))
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	print3(a) 		for(auto i : a)cout<<i<<nl;
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

// ostringstream str1;
// str1 << n;
// string tmp = str1.str();
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }
 
bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }
 
double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

////////////////// Inverse Modulo //////////////////////

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

ll fermat_inv(ll y){return power(y, mod-2);}
//////////////////////////////////////////////////////////

vll pwx(10);
void cal(ll x){ pwx[0] = 1; rep(i, 1, 10)pwx[i] = x*pwx[i-1]; }
 
/* ################################################################ */

#define space 1000005

void solve() {
    ll n, x, t;
    cin >> n >> x >> t;
    ll ans = (n/x)*t;
    if(n%x) ans += t;

    cout << ans << nl;
}

int main(){
    boost;
    // cal(3);

    // // For getting input from input.txt file 
    // freopen("perimetric_chapter_1_input.txt", "r", stdin); 
  
    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout);


    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 3648
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll N;
		lls P;

		cin >> N;
		cinv(P, N);

		lls loc(N+1);
		for (ll lc = 0; lc < N; lc++) {
			ll number = P[lc];
			loc[number] = lc;
		}

		lls locB;
		locB.push_back(loc[N]);

		ll A, B, C, D, E,sum=0;
		for (int i = N - 1; i >= 1; i--) {

			//数字iの場所lcが、locBに入る場所idxを得る
			ll lc = loc[i];
			C = lc;
			auto idxit = std::lower_bound(locB.begin(), locB.end(), lc);
			ll idx = idxit - locB.begin();
			
			//右側に大きいものがある場合を計算
			if (idx < locB.size()) {
				D = locB[idx];
				if (idx + 1 >= locB.size()) E = N;
				else                        E = locB[idx + 1];
				if (idx - 1 < 0) B = -1;
				else             B = locB[idx - 1];

				sum += (C - B) * (E - D) * i;
			}
			//左側に大きいものがある場合を計算
			if (idx - 1 >= 0) {
				B = locB[idx - 1];
				if (idx < locB.size()) D = locB[idx];
				else                   D = N;

				if (idx - 2 < 0) A = -1;
				else             A = locB[idx - 2];

				sum += (B - A) * (D - C) * i;
			}
			//locBの更新
			locB.insert(idxit, C);
		}

		cout << sum << '\n';

		return 0;
	}



Measured memory_bytes: 2936