akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stack>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<time.h>
using namespace std;

typedef long long ll;
int a[100];


int main() {
	//freopen("run.in", "r", stdin);
	//freopen("run.out", "w", stdout);

	int n;
	while (cin >> n) {
		for (int i = 0; i < n; i++)
			scanf("%d", &a[i]);
		cout << a[0];
		for (int i = 1; i < n; i++) {
			cout << ' ' << a[i];
		}
		cout << endl;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < i; j++) {
				if (a[i] < a[j]) {
					int temp = a[i];
					for (int k = i; k >= j + 1; k--) {
						a[k] = a[k - 1];
					}
				
					a[j] = temp;
				
				}
			
			}
			cout << a[0];
			for (int i = 1; i < n; i++) {
				cout << ' ' << a[i];
			}
			cout << endl;
		}
	}


	return 0;

}

Measured memory_bytes: 3216
#include <stdio.h>
void trace (int A[],int N){
	int i;
	for(i = 0; i < N; i++){
		if(i > 0){printf(" ");}
		printf("%d",A[i]);
	}
	printf("\n");
	return;
}
void sort(int A[],int N){
	int i,j,v;
	for(i = 1; i < N; i++){
		v = A[i];
		j = i-1;
		while(j >= 0 && A[j] > v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A,N);
	}
	return;
}
int main(void){
	int r,R[100],i;
	scanf("%d",&r);
	for(i = 0; i < r; i++){scanf("%d",&R[i]);}
	trace(R,r);
	sort(R,r);
	return 0;
}


Measured memory_bytes: 2096
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file = 1



    
def solve():


    
    # for _ in range(ii()):

        
       
        n = ii()
        a = li()
        s = 0
        for i in range(1,n):
            if a[i]<a[i-1]:
                s += (a[i-1]-a[i])
                a[i] = a[i-1]
        print(s)








        
if __name__ =="__main__":

    if(file):

        if path.exists('input.txt'):
            sys.stdin=open('input.txt', 'r')
            sys.stdout=open('output.txt','w')
        else:
            input=sys.stdin.readline
    solve()


Measured memory_bytes: 95120
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type city struct {
	id    int
	pref  int
	birth int
}

type cities []city

func (s cities) Len() int {
	return len(s)
}

func (s cities) Less(i, j int) bool {
	return s[i].birth < s[j].birth
}

func (s cities) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())

	allCities := make([]cities, N)
	for i := 0; i < N; i++ {
		allCities[i] = make(cities, 0)
	}

	for i := 0; i < M; i++ {
		sc.Scan()
		p, _ := strconv.Atoi(sc.Text())

		sc.Scan()
		y, _ := strconv.Atoi(sc.Text())

		allCities[p-1] = append(allCities[p-1], city{
			id:    i,
			pref:  p,
			birth: y,
		})
	}

	for i := 0; i < N; i++ {
		sort.Sort(allCities[i])
	}

	result := make([]string, M)
	for _, cs := range allCities {
		for i, c := range cs {
			result[c.id] = fmt.Sprintf("%06d%06d", c.pref, i+1)
		}
	}

	writer := bufio.NewWriter(os.Stdout)
	for _, s := range result {
		writer.WriteString(s + "\n")
	}
	writer.Flush()
}


Measured memory_bytes: 16512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int main() {
	int n, m, i, l, r, ml, mr;
	cin >> n >> m;
	ml = 1;
	mr = n;
	for (i = 0; i < m; i++) {
		cin >> l >> r;
		ml = max(ml, l);
		mr = min(mr, r);
	}
	if (ml <= mr)
		cout << mr - ml + 1 << endl;
	else
		cout << "0" << endl;
}


Measured memory_bytes: 4992
// AOJ 2707: Jail
// 2017.10.9 bal4u@uu

#include <stdio.h>

#define MAX 1000000000000000000LL
int n, k;

int check(long long m)
{
	int i;
	for (i = 0; i < n-1; i++) {
		m -= (m - 1) / k + 1;
        if (m <= 0) return 1;
    }
    return 0;
}

long long bsch()
{
	long long m, l = 0, r = MAX;
    while (l+1 < r) {
        m = (l + r) >> 1;
        if (check(m)) l = m; else r = m;
    }
	return l;
}

int main()
{
	scanf("%d%d", &n, &k);
	printf("%lld\n", bsch());
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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 int mod  = 2019;

int main(){
    
    string s;
    cin >> s;
    int n = sz(s);
    int ten = 1;
    V<int> a(n);
    for(int i = n-1; i >= 0; i--) {
        int c = s[i] - '0';
        a[i] = ten * c % mod;
        ten = ten * 10 % mod;
    }
    V<int> sum(n+1);
    sum[0] = 0;
    map<int, int> mp;
    mp[0]++;
    Rep(i,n) {
        sum[i] = (sum[i-1] + a[i-1]) % mod;
        mp[sum[i]]++;
    }

    ll ans = 0;
    for(P p : mp) {
        ans += p.se * (p.se-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	string s;
	cin >> s;
	int n = s.size();
	int cnt = 0;
	int i = 0;
	int y = 0;
	while (i < n)
	{
		if (s[i] == 'B')
		{
			//int y = 0;
			while (s[i] == 'B' && i < n)
			{
				i++;
				//cnt++;
				y++;
			}

			int x = 0;
			while (s[i] == 'W' && i < n)
			{
				i++;
				x++;
			}
			cnt += x * y;
		}
		else
		{
			while (s[i] == 'W')
			{
				i++;
			}
		}
	}
	cout << cnt << en;

	return 0;
}



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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    vector<int> a(3);

    int max=0,sum=0;
    for(int i=0;i<3;i++){
        cin>>a.at(i);
        if(a.at(i)>max){
            max = a.at(i);
        }
        sum += a.at(i);
    }
    int z;
    cin>>z;
    sum -= max;
    max *= pow(2,z);
    cout<<sum+max<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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 long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}


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

    double ans=0.0;
    rep(i,N){
        int a;
        cin >>a;
        ans += (double) 1/a;
    }


    cout << fixed << setprecision(10) << 1/ans << endl;
}

Measured memory_bytes: 3752
fun main(args: Array<String>) {
    val (k, x) = readLine()!!.split(" ").map(String::toInt)
    var result = ""

    val minPos = Math.max(-1000000, x - k + 1)
    val maxPos = Math.min(1000000, x + k - 1)
    for (i in minPos..maxPos) {
        result += "$i "
    }
    println(result.substring(0, result.length - 1))
}

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

using ll = long long;

int main(){
  int N,K;
  cin >> N >> K;
  vector<long long int> H(N+1);
  rep(i,N){cin >> H[i];}

  sort(H.begin(),H.end());

  long long int atksum = 0;
  for(int i=0;i<N-K+1;i++){
    atksum += H[i];
  }
  cout << atksum << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  vector<string> three{
    {"aa."},
    {"..b"},
    {"..b"}
  };
  vector<vector<string> > s{
  {
    {"aabc"},
    {"ddbc"},
    {"efgg"},
    {"efhh"}
  },
  {
    {"aabcc"},
    {"d.bee"},
    {"dff.g"},
    {"hi..g"},
    {"hijj."}
  },
  {
    {"aa.b.cc"},
    {"d..bee."},
    {"d.ff..g"},
    {".hh.i.g"},
    {"j.kki.."},
    {"jl....m"},
    {".l..nnm"}
  }};
  int n; cin >> n;
  if (n == 2) {
    cout << -1 << '\n';
    return 0;
  }
  vector<vector<char> > ans(n, vector<char>(n, '.'));
  if (n == 3 || n == 6) {
    for (int i = 0; i < n; i += 3) {
      REP(y, 3) REP(x, 3) ans[i + y][i + x] = three[y][x];
    }
  } else {
    vector<vector<int> > memo{
      {},
      {},
      {},
      {},
      {0},
      {1},
      {},
      {2},
      {0, 0},
      {0, 1},
      {1, 1}
    };
    vector<int> parts;
    int N = n;
    while (N > 10) {
      parts.emplace_back(0);
      N -= 4;
    }
    for (int e : memo[N]) parts.emplace_back(e);
    int idx = 0;
    for (int i = 0; i < n;) {
      REP(y, s[parts[idx]].size()) REP(x, s[parts[idx]].size()) ans[i + y][i + x] = s[parts[idx]][y][x];
      i += s[parts[idx++]].size();
    }
  }
  REP(i, n) {
    REP(j, n) cout << ans[i][j];
    cout << '\n';
  }
  return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = pow(n,0.5);
    ans = pow(ans,2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

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

    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(), h.end());

    int ans = INF;
    int temp;
    int hmax;
    int hmin;
    for (int i = 0; i < N - K + 1; i++)
    {
        hmin = h[i];
        hmax = h[i + K - 1];
        // printf("hmin = %d, hmax = %d\n", hmin, hmax);
        temp = hmax - hmin;
        ans = min(ans, temp);
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 768
using System;

namespace ITP1_7_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int r = int.Parse(strs[0]);
            int c = int.Parse(strs[1]);
            int[,] m = new int[r + 1, c + 1];
            for (int i = 0; i < r; i++)
            {
                string[] row = Console.ReadLine().Split(' ');
                for (int j = 0; j < c; j++) m[i, j] = int.Parse(row[j]);
            }
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++) m[i, c] += m[i, j];
            }
            for (int j = 0; j <= c; j++)
            {
                for (int i = 0; i < r; i++) m[r, j] += m[i, j];
            }
            for (int i = 0; i < r; i++)
            {
                for (int j = 0; j < c; j++) Console.Write(m[i, j] + " ");
                Console.WriteLine(m[i, c]);
            }
            for (int j = 0; j < c; j++) Console.Write(m[r, j] + " ");
            Console.WriteLine(m[r, c]);
        }
    }
}

Measured memory_bytes: 9288
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
  	val a = sc.nextInt()
  	val b = sc.nextInt()
  	val c = sc.nextInt()
    var max = a
    if (b>max) max = b
    if (c>max) max = c
    println(a*b*c/max/2)
}


Measured memory_bytes: 31276
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

int main(){
  int n;
  ll a[100000];
  cin>>n;
  for (int i(0);i<n;i++) cin>>a[i];
  sort(a,a+n,greater<ll>());
  int cnt(1);
  int cnt2(0);
  ll ans(1);
  for (int i(1);i<n;i++){
    if (a[i]==a[i-1]){
      cnt++;
    }else{
      cnt=1;
    }
    // cerr<< cnt<< " ";
    if (cnt==2){
      cnt=1;
      cnt2++;
      cerr<<a[i]<<endl;
      ans*=a[i];
      i++;
    }
    if (cnt2==2){
      // cerr<<"++++++"<< endl;
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


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

int main(){
    string s1,s2;
    cin >> s1 >> s2;
    int s1len = (int)s1.size();
    int s2len = (int)s2.size();

    vector<vector<int> > D(s1len+1 ,vector<int>(s2len+1, 0));

    // ?¢?????????¶
    for(int i=0;i<=s1len;++i){
      D[i][0]=i;
    }
    for(int i=0;i<=s2len;++i){
      D[0][i]=i;
    }

    for(int i=1;i<=s1len;++i){
        for(int j=1;j<=s2len;++j){
            if(s1[i-1] == s2[j-1]){ // D??¨???index?????????????????¨?????¨??????
                D[i][j] = D[i-1][j-1];
            } else {
                D[i][j] = min(D[i-1][j-1]+1,min(D[i-1][j]+1,D[i][j-1]+1));
            }
        }
    }
    cout << D[s1len][s2len] << endl;
}

Measured memory_bytes: 6812
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define sqr(x) x * x
class CXYZTriplets {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        ll limit = 10000;

        vector<ll> a(limit + 1);
        for(ll i = 1; i * i <= limit; i++)
            for (ll j = 1; j * j <= limit;++j)
                for (ll k = 1; k * k <= limit; ++k) {
                    ll t = sqr(i) + sqr(j) + sqr(k) + i * j + j * k + i * k;
                    if (t <= limit){
                        a[t]++;
                    }
                }
        ll n;
        cin >> n;

        for (ll l = 1; l <= n; ++l) {
            cout << a[l] << endl;
        }

	}
};


int main() {
	CXYZTriplets solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>
#include <math.h>
 
int main(void) {
 
  int d,t;
  double x=0.0,y=0.0;
  int ang=90.0;
 
  while(1) {
 
    scanf("%d,%d",&d,&t);
 
    if(d==0 && t==0) break;
     
    x+=(double)d*cos((double)ang*M_PI/180.0);
    y+=(double)d*sin((double)ang*M_PI/180.0);
 
    ang-=(double)t;
  }
 
  printf("%d\n%d\n",(int)x,(int)y);
 
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int n;
  cin>>n;
  int res = 1;
  int odd_prod = 1;
  RE (i, n) {
    int a;
    cin>>a;
    res *= 3;
    if (a % 2 == 0) {
      odd_prod *= 2;
    }
  }
  cout<<res - odd_prod<<endl;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&& b==c)
    {
        cout<<"1"<<endl;
    }
    else if(a==b || b==c || a==c)
    {
        cout<<"2"<<endl;
    }
    else
        cout<<"3"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
int n;
int m;
int b;
int c;
int d;
int e;
while(cin >>n){
cin >>m;
if(n==0){break;}
int a[m];
b=0;
while(b<m){
a[b]=0;
b=b+1;}
b=0;
while(b<n){
c=0;
while(c<m){
cin >>d;
if(d==1){a[c]=a[c]+1;}
c=c+1;}
b=b+1;}
e=0;
b=n;
while(b>=0){
c=0;
while(c<m){
if(a[c]==b){cout << c+1; e=e+1;
if(e==m){cout <<endl;}
else{cout <<" ";}}
c=c+1;}
b=b-1;}
}
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){
  int r, c, i, j, s[128][128] = {};
  scanf("%d%d", &r, &c);
  for(i = 0;i < r;i++){
    for(j = 0;j < c;j++){
      scanf("%d", &s[i][j]);
      s[i][c] += s[i][j]; s[r][j] += s[i][j]; s[r][c] += s[i][j];
    }
  }

  for(i = 0;i <= r;i++){
    for(j = 0;j <= c;j++)
      printf(j != 0 ? " %d" : "%d", s[i][j]);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 684
#include <cstdio>
#include <cstring>
#include <cstdlib>
typedef struct Node {
    int id;
    struct Node *left;
    struct Node *right;
} Node;

Node *insert_iter(Node *t, Node *z){
    if(t == nullptr) return z;
    if(z->id <= t->id) t->left = insert_iter(t->left, z);
    else t->right = insert_iter(t->right, z);
    return t;
}

void insert(Node **root, Node *z){
    *root = insert_iter(*root, z);
}

bool search(Node *node, int id){
    if(node == nullptr) return false;
    else if(id < node->id) return search(node->left, id);
    else if(id > node->id) return search(node->right, id);
    return true;
}

void print_inorder(Node *node){
    if(node == nullptr) return;
    print_inorder(node->left);
    std::printf(" %d",node->id);
    print_inorder(node->right);
}

void print_preorder(Node *node){
    if(node == nullptr) return;
    std::printf(" %d", node->id);
    print_preorder(node->left);
    print_preorder(node->right);
}

void deleteNode(Node *node){
    if(node == nullptr) return;
    deleteNode(node->left);
    deleteNode(node->right);
    free(node);
}

int main(){
    int n;
    std::scanf("%d", &n);
    Node *root = nullptr;
    int nodeNum = 0;
    for(int i = 0; i < n; ++i){
        char op[8];
        std::scanf("%s", op);
        if(std::strncmp(op, "insert", 6) == 0){
            int v;
            std::scanf("%d", &v);
            Node *node = (Node *)std::malloc(sizeof(Node));
            node->id = v;
            node->left = nullptr;
            node->right = nullptr;
            insert(&root, node);
	} else if(std::strncmp(op, "find", 4) == 0){
            int v;
            std::scanf("%d", &v);
            if(search(root, v) == true) std::printf("yes\n");
            else std::printf("no\n");
        } else if(std::strncmp(op, "print", 5) == 0){
            print_inorder(root);
            std::printf("\n");
            print_preorder(root);
            std::printf("\n");
        }
    }

    return 0;
}




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

int N;
int K;
int dp[100010];
int h[100010];

int main()
{
    cin >> N >> K;
    for(int i = 1; i <= N; i++ ) cin >> h[i];

    dp[1] = 0;
    for(int j = 2; j <= N; j++)
    {
        if(K >= j)
        {
            int mindp = INT_MAX;
            for(int l = 1; l <= j - 1; l++) mindp = min(mindp, dp[l] + abs(h[j] - h[l]));
            dp[j] = mindp;
        }
        else
        {
            int mindp = INT_MAX;
            for(int m = j - K; m <= j - 1; m++) mindp = min(mindp, dp[m] + abs(h[j] - h[m]));
            dp[j] = mindp;
        }
    }
    cout << dp[N] << endl;

}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<algorithm>
 
using namespace std;
 
const int N = 1000005;
 
int n;
char s[N];
int t[N];
 
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++) s[i]--;
	
	int sum=0,c=0;
	t[0]=t[1]=0;
	for(int i=2;i<=n;i++)
		if(i&1) t[i]=0;
		else t[i]=t[i/2]+1;
	for(int i=1;i<=n;i++){
		if(i>1) c+=t[n-i+1]-t[i-1];
		if(s[i]=='1' && c==0) sum^=1;
	}
	if(sum==1) { printf("1\n"); return 0; }
	
	for(int i=1;i<=n;i++)
		if(s[i]=='1') { printf("0\n"); return 0; }
	
	sum=0; c=0;
	for(int i=1;i<=n;i++){
		if(i>1) c+=t[n-i+1]-t[i-1];
		if(s[i]=='2' && c==0) sum^=1;
	}
	if(sum==1) printf("2\n");
	else printf("0\n");
	
	return 0;
}

Measured memory_bytes: 8628
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    for(int i = 0; i < n; i++){
        cin >> v[i] ; 
    }
    vector<int> first(n) , second(n) ;
    for(int i = 0; i < n; i++){
        first[i] = v[i] + i ;
        second[i] = i - v[i] ;
    }
    debug() << imie(first) ;
    debug() << imie(second) ;
    map<int,vector<int> > mp ;
    for(int i = 0; i < n; i++){
        mp[second[i]].push_back(i) ;
    }
    int ans = 0 ;
    for(int i = 0; i < n; i++){
        vector<int> &t = mp[first[i]] ;
        if ( t.empty() ) continue ;
        ans += (int)t.size() - (upper_bound(t.begin(), t.end(), i) - t.begin() );
    }
    cout << ans << endl ;
    return 0; 
}


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

#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++)

int main()
{
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    sort(v.begin(), v.end());

    int dist = k - v[n - 1] + v[0];
    rep2(i, 1, n)
    {
        dist = max(dist, v[i] - v[i - 1]);
    }
    cout << k - dist << endl;

    return 0;
}


Measured memory_bytes: 1024
n = int(input())

words = [input() for _ in range(n)]

spoken = {words[0]}

for x, y in zip(words, words[1:]):
    if y[0] != x[-1]:
        print("No")
        exit()
    if y in spoken:
        print("No")
        exit()
    spoken.add(y)
else:
    print("Yes")

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

using namespace std;

const int maxn = 210;

int fac[maxn], ifac[maxn], dp[maxn][maxn], sum[maxn][maxn];
int n, K, mod, ans;

int qpow(int x, int y) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1LL * ret * x % mod;
		x = 1LL * x * x % mod;
		y >>= 1;
	}
	return ret;
}

int binom(int x, int y) {
	if (y > x) return 0;
	return 1LL * fac[x] * ifac[x-y] % mod * ifac[y] % mod;
}

int main() {
	scanf("%d%d%d", &n, &K, &mod);
	fac[0] = 1; for (int i = 1; i <= n; i++) fac[i] = 1LL * fac[i-1] * i % mod;
	for (int i = 0; i <= n; i++) ifac[i] = qpow(fac[i], mod-2);
	for (int T = 0; T <= K; T++) {
		// max in-deg <= K-T
		// |V| = n - T
		int res = 0, c = n - T;
		if (c == 1) {
			res = 1;
		} else {
			if (K - T <= 0) continue;
			// min out-deg >= (c-1)-(K-T)
			int m = max(1, c - 1 - (K - T));
			for (int s = m; s <= c - 2; s++) {
				for (int i = 1; i <= c - 1; i++) dp[1][i] = 0;
				dp[1][s] = 1;
				for (int i = 1; i <= c - 1; i++) sum[1][i] = (sum[1][i-1] + dp[1][i]) % mod;
				for (int i = 2; i <= s + 1; i++) {
					for (int j = 0; j <= c - 1; j++) dp[i][j] = 0;
					for (int j = m; j <= (c - 1 - m); j++) {
						dp[i][j] = sum[i-1][j+1];
					}
					for (int j = 1; j <= c - 1; j++) sum[i][j] = (sum[i][j-1] + dp[i][j]) % mod;
				}
				int add = sum[s + 1][c - s - 1];
				res = (res + add) % mod;
			}
		}
		res = 1LL * res * fac[c - 1] % mod * binom(n, T) % mod * fac[T] % mod; 
		ans = (ans + res) % mod;	
	}
	printf("%d\n", ans);
	return 0;
}

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

int main(){
  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: 3636
#include <iostream>
#include <map>
using namespace std;

int main() {
  int n;
  map<string, int> map;

  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    map[s]++;
  }

  cout << map.size() << endl;

}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int M, K; cin >> M >> K;

  int N = exp2(M);
  if (K>=N) END(-1);
  if (M==0) END("0 0");
  if (M==1 and K==1)  END(-1);
  if (M==1 and K==0)  END("0 0 1 1");
  rep(i,0,N-1) if (i!=K) cout<< i << " ";       cout << K << " ";
  rep(i,0,N-1) if (i!=(N-1-K)) cout<< N-1-i << " ";   cout << K << endl;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

string t = "CODEFESTIVAL2016";

int main() {
	string s;
	cin >> s;
	int ret = 0;
	rep(i, 16) ret += (s[i]!=t[i]);
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        NotDivisible solver = new NotDivisible();
        solver.solve(1, in, out);
        out.close();
    }

    static class NotDivisible {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
            }
            Arrays.sort(nums);

            int max = nums[n - 1];
            int[] count = new int[max + 1];
            boolean[] divs = new boolean[max + 1];

            for (int i = 0; i < n; i++) {
                count[nums[i]] += 1;
                divs[nums[i]] = true;
            }

            for (int i = 0; i < n; i++) {
                int base = nums[i];
                int loop = base + base;
                while (loop <= max) {
                    divs[loop] = false;
                    loop += base;
                }
            }

            int result = 0;
            for (int i = 0; i < n; i++) {
                if (divs[nums[i]] && count[nums[i]] == 1) {
                    result++;
                }
            }
            out.append(String.valueOf(result));
        }

    }
}



Measured memory_bytes: 63416
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int N,T,E;
    int sand;
    cin>>N>>T>>E;
    for(int i=1;i<=N;i++){
        cin>>sand;
        if((T+E)%sand<=E){cout<<i<<endl;return 0;}
    }
    cout<<"-1"<<endl;
    return 0;
}

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

int main() {
  int N,a,b,c,d;
  cin >> N;
  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = (N-a*1000-b*100-c*10)/1;
  if(a==b && b==c){
    cout << "Yes" << endl;
  }else if(b==c && c==d){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void PR(bool f){
  cout << (f ? "YES" : "NO") << endl;
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(ALL(a));
  repr(i, 1, n){
    if(a[i] == a[i-1]){
      PR(0);
    }
  }
  PR(1);
}


Measured memory_bytes: 1792
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  string n;cin>>n;
  if(n[0]=='9'||n[1]=='9')puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
INF = 1000000007
H.append(INF)
ans = 0
res = 0
for i in range(N):
  if(H[i] >= H[i+1]):
    res += 1
  else:
    if(ans < res): ans = res
    res = 0
print(ans)

Measured memory_bytes: 15020
#include<stdio.h>
int main(){
	int i,N,x[365],y[365],b[365],p[365],a[365],c[365],d[365],e[365],f[365],g[365],h[365];
	scanf("%d",&N);
		
	for(i=0;i<N;i++){
		scanf("%d %d %d %d",&x[i],&y[i],&b[i],&p[i]);
	}
	
	for(i=0;i<N;i++){
		a[i]=x[i]*b[i]+y[i]*p[i];
		c[i]=x[i]*5+y[i]*p[i];
		d[i]=x[i]*b[i]+y[i]*2;
		e[i]=x[i]*5+y[i]*2;
		f[i]=c[i]*8;
		g[i]=d[i]*8;
		h[i]=e[i]*8;
		
		if(b[i]>=5&&p[i]>=2){
			a[i]*=8;
			a[i]/=10;
		}	
		if(b[i]<5&&p[i]>=2){
			if(a[i]>f[i]/10){
				a[i]=f[i]/10;
			}
		}
		else if(p[i]<2&&b[i]>=5){
			if(a[i]>g[i]/10){
				a[i]=g[i]/10;
			}
		}
		else if(b[i]<5&&p[i]<2){
			if(a[i]>h[i]/10){
				a[i]=h[i]/10;
			}
		}
		printf("%d\n",a[i]);
	}
return 0;
}

Measured memory_bytes: 612
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse = True)
Q = sorted(list(map(int, input().split())), reverse = True)
R = sorted(list(map(int, input().split())), reverse = True)

res = sum(P[0:X]) + sum(Q[0:Y])
p_min_idx = X-1
q_min_idx = Y-1
for r in R:
    if (p_min_idx < 0 and q_min_idx >= 0) or (p_min_idx >= 0 and q_min_idx >= 0 and P[p_min_idx] > Q[q_min_idx]):
        if Q[q_min_idx] < r:
            res = res - Q[q_min_idx] + r
            q_min_idx -= 1
        else:
            break
    else:
        if p_min_idx >= 0 and  P[p_min_idx] < r:
            res = res - P[p_min_idx] + r
            p_min_idx -= 1
        else:
            break

print(res)


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

int main(){
    int a,b;
    cin >> a >> b;
    int c = b / 2; 
    if(a <= 5){
        cout << "0";
    }else if(a >= 6 && a <= 12 ){
        cout << c ;
    }else if(a >= 13){
        cout << b;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

struct Solver
{
	const int N, M, P;
	vector<VVI> board;

	Solver( int n, int m, int p ) : N( n ), M( m ), P( p ), board( N, VVI( N ) )
	{
		return;
	}

	operator string()
	{
		VI xs( P ), ys( P );
		REP( i, 0, P )
		{
			cin >> xs[i] >> ys[i];
		}

		REP( i, 0, P )
		{
			int x = xs[i] - 1, y = ys[i] - 1;
			board[y][x].PB( i % 2 );
			if ( check( i % 2 ) )
			{
				i++;
				OSS oss;
				oss << i;
				return string( i % 2 ? "Black" : "White" ) + ' ' + oss.str();
			}
		}
		return "Draw";
	}

	bool check( const int p )
	{
		REP( y, 0, N )
		{
			REP( x, 0, N )
			{
				REP( z, 0, N )
				{
					REP( dy, -1, 2 )
					{
						REP( dx, -1, 2 )
						{
							REP( dz, -1, 2 )
							{
								if ( !( dy | dx | dz ) )
								{
									continue;
								}
								if ( M <= rec( y, x, z, p, dy, dx, dz ) )
								{
									return true;
								}
							}
						}
					}
				}
			}
		}
		return false;
	}

	int rec( int y, int x, int z, int p, int dy, int dx, int dz )
	{
		if ( !( 0 <= y && y < N && 0 <= x && x < N && z < board[y][x].size() ) )
		{
			return 0;
		}
		if ( board[y][x][z] != p )
		{
			return 0;
		}
		return 1 + rec( y + dy, x + dx, z + dz, p, dy, dx, dz );
	}
};

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

	for ( int n, m, p; cin >> n >> m >> p, n | m | p; )
	{
		cout << (string)Solver( n, m, p ) << endl;
	}

	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int solve(Int A, Int B, Int C, Int D){
  if(A < B) return 0;
  if(D < B) return 0;
  if(C >= B) return 1;

  A %= B;
  D %= B;
  if(D == 0) return A <= C;
  Int d = __gcd(B, D);
  Int num = (B - A - 1) / d;
  //pr(A, B, C, D, num);
  A += num * d;
  return A <= C;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int T;
  cin>>T;
  while(T--){
    Int A, B, C, D;
    cin>>A>>B>>C>>D;
    Int ans = solve(A, B, C, D);
    cout<<(ans? "Yes":"No")<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>


int Big(int a,int b){
  return (a<b)?b:a;
}

int LCS(char *A,char *B){//同じ順番の最長文字数
  int M[1001][1001];
  int i,j;
  int Asize,Bsize;
  int max=0;
  
  Asize=strlen(&A[1]);  //gyou i
  Bsize=strlen(&B[1]); //retu j

  
  for(i=0;i<1001;i++)M[i][0]=0;
  for(i=0;i<1001;i++)M[0][i]=0;

  for(i=1;i<=Asize;i++){
    for(j=1;j<=Bsize;j++){
      if(A[i]==B[j])M[i][j]=M[i-1][j-1]+1;
      else M[i][j]=Big(M[i-1][j],M[i][j-1]);
     
      max=Big(max,M[i][j]);
    }
  }
  return max;
}

int main(){
  int n;
  int i;
  char A[1002],B[1002];
 
  scanf("%d",&n);//比較する組数
 
  for(i=0;i<n;i++){
    scanf("%s%s",&A[1],&B[1]);//文字用;
    printf("%d\n",LCS(A,B));//何文字一緒だったか
  }

  return 0;
}



Measured memory_bytes: 5772
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
    String data = String.valueOf(a);
    String answer = "";

    for (int i = 0; i < data.length(); i++) {
      String num = String.valueOf(data.charAt(i));
      int n = Integer.parseInt(num);
      if (n == 9) {
        answer += "1";
      } else {
        answer += "9";
      }
    }
    System.out.println(answer);
	}
}


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

int main() {
  rep(i, 5) {
    int x; cin >> x;
    if (x == 0) {
      cout << i+1 << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
	int a,b;
	
	
	scanf("%d",&a); 
	scanf("%d",&b);
	
	if(a<b)
	   puts("a < b");
	if(a>b)
	   puts("a > b");
	if(a==b)
	   puts("a == b");
	return 0;
}

Measured memory_bytes: 580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    // ll n, k;
    // cin >> n >> k;
    // ll ans = n; //ans = 7
    // while (ans > abs(ans - k))
    // {
    //     ans = min(ans, abs(ans - k));
    // }
    // cout << ans << endl;
    // return 0;

    ll n, k;
    cin >> n >> k;
    if (n % k == 0)
    {
        cout << 0 << endl;
    }
    else if (n < k)
    {
       cout << min(n, abs(n - k)) << endl;
    }
    else {
        cout << min(n % k, abs(n % k - k)) << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main (void){
    int n;
    int grp[200000]={0};
    int huka=0;
    scanf("%d",&n);
    //もし、nが奇数→0 202 42024 6420246
    //もし、nが偶数→11 3113 531135   でなければならない
    int data[n];
    int loop1;
    for(loop1=0;loop1<n;loop1++){
        scanf("%d",&data[loop1]);
        grp[data[loop1]]++;
    }
    //不可能かチェック
    for(loop1=0;loop1<n;loop1++){
        if(n%2==0){
            if(loop1%2==0 && grp[loop1]!=0){
                huka=-1;
            }
            if(loop1%2==1 && grp[loop1]!=2){
                huka=-1;
            }
        }
        if(n%2==1){
            if(loop1==0){
                if(grp[loop1]!=1){
                    huka=-1;
                }
            }else if(loop1%2==1 && grp[loop1]!=0){
                huka=-1;
            }else if(loop1%2==0 && grp[loop1]!=2){
                huka=-1;
            }
        }
    }
    if(huka==-1){
        printf("0\n");
        return 0;
    }
    //パターン数はいくつか
    int teisu=(int)pow(10,9)+7;
    int patt=1;
    for(loop1=0;loop1<(n/2);loop1++){
        patt*=2;
        patt%=teisu;
        //printf("%lld\n",patt);
    }
    printf("%d\n",patt);
    return 0;
}

Measured memory_bytes: 1280