akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

ll md = 1000000000+7;
ll memo[1020][1020];
char C[1020][1020];
int n,m;
ll dp(ll x, ll y) {
    if(x == n-1 && y == m-1) return 1;
    if(x >= n || y >= m) return 0;
    if(C[x][y] == '#') return 0;
    if(memo[x][y] != -1) return memo[x][y];
    return memo[x][y] = (dp(x+1,y)+dp(x,y+1))%md;
}

int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n >> m;
    rep(i,0,n) rep(j,0,m) cin >> C[i][j];
    cout << dp(0,0) << endl;
    return 0;
}


Measured memory_bytes: 9472
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  ll n, k, s;
  cin >> n >> k >> s;
  rep(i, n)
  {
    if (i < k)
      cout << s;
    else
      cout << (s == INF ? INF - 1 : s + 1);
    cout << (i == n - 1 ? "\n" : " ");
  }
  return 0;
}

Measured memory_bytes: 1280
class ModCombination
  attr_reader :fac, :inv, :finv, :mod

  MOD = 10 ** 9 + 7

  def initialize(n, mod: MOD)
    @mod = mod
    @fac = [1, 1]
    @inv = [1, 1]
    @finv = [1, 1]

    (2..n).each do |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
    end
  end

  def combination(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0

    fac[n] * (finv[k] * finv[n - k] % mod) % mod
  end

  def repeated_combination(n, k)
    combination(n + k - 1, k)
  end
end

MOD = 10 ** 9 + 7
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort

if K == 1
  puts 0
  exit
end

ans = 0
mc = ModCombination.new(N + 1)

N.times do |i|
  a = A[i]

  if i <= N - K + 1
    ans += -a * mc.combination(N - i - 1, K - 1)
  end

  if i >= K - 1
    ans += a * mc.combination(i, K - 1)
  end

  ans %= MOD
end

puts ans


Measured memory_bytes: 12924
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
#include<iomanip>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef vector<string> vstring;
typedef vector<vector<string>> vvstring;
typedef vector<char> vchar;
typedef vector<vector<char>> vvchar;
typedef vector<long double> vdouble;
typedef vector<vector<long double>> vvdouble;
typedef vector<vector<vector<long double>>> vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define DIVIDER 1000000007


//
// struct Node{
//   vint children;
//   ll index;
//   ll prop;
// };
// struct edge{ll to; ll cost;};



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }

// ll get_pow(ll x, ll y){
//   ll ret=0;
//   ll temp = y;
//   while(true){
//     if(x<=temp) break;
//     ret++;
//     temp *= 2;
//   }
//   return ret;
// }






int main() {
  cout<<fixed<<setprecision(10);

  ll Q;cin>>Q;
  vint l(Q),r(Q);rep(i,Q)cin>>l[i]>>r[i];

  ll ans;


  bool primes[100001];
  rep(i,100001) primes[i]=true;
  primes[0]=false;
  primes[1]=false;
  repf(i,2,sqrt(100001)){
    if(primes[i]){
      for(ll j=0;i*(j+2)<100001;j++){
        primes[i*(j+2)] = false;
      }
    }
  }

  vint rui(100002,0);
  rep(i,100001){
    rui[i+1] = rui[i];
    if(primes[i] && primes[(i+1)/2]){
      rui[i+1]++;
    }
  }

  rep(i,Q){
    cout << rui[r[i]+1]-rui[l[i]] << endl;
  }



  // cout << ans << endl;
}

















//


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



class Program
{
    const int MOD = 1000000007;
    const int INF = 1 << 30;

    static void Main(string[] args)
    {
        Solve();
    }




    static void Solve()
    {
        Scan sc = new Scan();
        write wr = new write();

        string s = sc.str;
        int ans = 0;
        for(int i = 0; i < 4; ++i)
        {
            if (s[i] == '+')
            {
                ans++;
            }
            else ans--;
        }
        wr.wri(ans);
    }
}
    




class Scan
{
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
    public char[] chararr => str.ToArray();


}



class write
{
    public void wri<Type>(Type x)
    {
        Console.WriteLine(x);
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
class Program
    {
        public static long Gcd(long a, long b) {
         if (a < b)
             // 引数を入替えて自分を呼び出す
             return Gcd(b, a);
         while (b != 0) {
             var remainder = a % b;
             a = b;
             b = remainder;
         }
         return a;
     }
        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split(' ');
            long a = long.Parse(s1[0]), b = long.Parse(s1[1]), c = long.Parse(s1[2]), d = long.Parse(s1[3]);

            long ans = b / c - (a - 1) / c;
            ans += b / d - (a - 1) / d;
            long cd = c * d / Gcd(c, d);

            ans -= b / cd - (a - 1) / cd;
            Console.WriteLine(b - a + 1 - ans);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  const char* result = "dangerous";
  if (B <= A) {
    result = "delicious";
  } else if (B - A <= X) {
    result = "safe";
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import random
import time
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def scorei(ti, i, last, minus):
        k = [i for i in last]
        mi = minus-(i+1-last[ti])*c[ti]
        v = s[i][ti]-mi
        mi += sum_
        k[ti] = i+1
        return v, k, mi

    def score(t):
        n = 26
        v = 0
        minus = sum_ = sum(c)
        last = [0]*n
        for i in range(d):
            ti = t[i]-1
            minus -= (i+1-last[ti])*c[ti]
            v += s[i][ti]-minus
            minus += sum_
            last[ti] = i+1
        return v
    start = time.time()
    d = I()
    c = LI()
    s = LIR(d)
    n = 26
    m = 10000
    sum_ = sum(c)
    q = [(0, 0, [0]*n, sum_)]
    pre = [[None]*n for i in range(d)]
    sc = [[float("inf")]*n for i in range(d)]
    argmax = 0
    for i in range(d):
        nq = []
        for _ in range(m):
            if not q:
                break
            v, x, last, minus = heappop(q)
            if i > 0 and v > sc[i-1][x]:
                continue
            for ti in range(n):
                vi,nl,nm = scorei(ti,i,last,minus)
                nv = v-vi
                heappush(nq,(nv,ti,nl,nm))
                if sc[i][ti] > nv:
                    sc[i][ti] = nv
                    pre[i][ti] = x
        q = [i for i in nq]
    t = []
    argmax = 0
    m = sc[-1][0]
    for i in range(1,n):
        sci = sc[-1][i]
        if m > sci:
            m = sci
            argmax = i
    t.append(argmax)
    x = argmax
    for i in range(1,d)[::-1]:
        y = pre[i][x]
        t.append(y)
        x = y
    t = [i+1 for i in t[::-1]]
    v = score(t)
    i = 0
    while time.time() < 1.8+start:
        nt = [i for i in t]
        r = random.randrange(1,n+1)
        nt[i] = r
        nv = score(nt)
        if v < nv:
            t = [i for i in nt]
            v = nv
        i += 1
        i %= d
    for i in t:
        print(i)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 117452
fun main(args: Array<String>) = abc163b()

fun abc163b() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val aList = readLine()!!.split(' ').map { it.toLong() }

    val answer = (n - aList.sum()).let { if (it < 0) -1 else it }

    println(answer)
}


Measured memory_bytes: 39840
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}


Measured memory_bytes: 3548
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n-2):
    if (max(p[i],p[i+1],p[i+2])==p[i] or max(p[i],p[i+1],p[i+2])==p[i+2]) and (min(p[i],p[i+1],p[i+2])==p[i] or min(p[i],p[i+1],p[i+2])==p[i+2]):
        ans+=1
print(ans)

Measured memory_bytes: 3064
// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 8.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}

#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n;
int a[3002];
int cache[3002][3002][2];

 


int dp(int l,int r,int turn){


 
	if(l>r or l==n or r==-1) return 0;

	int &ans=cache[l][r][turn];

	if(ans!=-1) return ans;



	if(turn==0)
		ans=max(a[l]+dp(l+1,r,turn^1),a[r]+dp(l,r-1,turn^1));
	else
		ans=min(dp(l+1,r,turn^1)-a[l],dp(l,r-1,turn^1)-a[r]);

	return ans;



}



 
void solve(){
 
 
	cin>>n;
	fr(i,0,n) cin>>a[i];

	memset(cache,-1,sizeof(cache));

	cout<<dp(0,n-1,0);




	
	

 
}
 



signed main() {
	fio;

	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


Measured memory_bytes: 141184
integer N
character(10) S
integer AB
integer CA,BC
integer BCA
integer Hosei
integer L
read*,N
AB=0;CA=0;BC=0;BCA=0
do i=1,N
  read*,S
  L=LEN_TRIM(S)
  do j=2,L
    if(S(j-1:j)=="AB")AB=AB+1
  end do
  if(S(1:1)=="B")BC=BC+1
  if(S(L:L)=="A")CA=CA+1
  if(S(1:1)=="B".and.S(L:L)=="A")BCA=BCA+1
end do

Hosei=0
if(BC==CA.and.BC==BCA)Hosei=1
if(BCA==0)Hosei=0

print"(i0)",AB+min(BC,CA)-Hosei

end

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
move = 0
count = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        move = max(move, count)
        count = 0
move = max(move, count)
print(move)

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

#ifdef _DEBUG
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout if (false) cout
#define debug() if (false)
#define dvout(v) if(false) vout(v)
#endif

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vec(v, n) vector<int> v(n, 0);
#define vecll(v, n) vector<ll> v(n, 0);
#define vecvec(v,n,m) vector<vector<int>> v(n, vector<int>(m));
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力

#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
#define next asdnext
#define prev asdprev
#define _n "\n"
#define _n2 "\n\n"
#define _t "\t"

void Main()
{
	int X;
	cin>>X;

	cout<<8+2-(X/200)<<_n;
}


void Test();
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
int N;
ll A[100001];
ll B[100001];
ll D1[100001];
ll D2[100001];
ll D[100001];

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

  cin >> N;
  rep(i, N) cin >> A[i];
  B[0]=A[0];
  rep(i, N-1){
    B[i+1] = B[i] + A[i+1];
  }
  ll ans1 = 0ll;
  ll cnt = 0ll;
  rep(i, N){
    if (i%2==0){
      if (B[i]+cnt>0) continue;
      else{
        ans1+=1-(B[i]+cnt);
        cnt+=1-(B[i]+cnt); 
      }
    } else{
      if (B[i]+cnt<0) continue;
      else{
        ans1+=B[i]+cnt-(-1);
        cnt-=(B[i]+cnt-(-1));
      }
    }
  }
  ll ans2 =0ll;
  cnt = 0ll;
  rep(i, N){
    if (i%2==1){
      if (B[i]+cnt>0) continue;
      else{
        ans2+=1-(B[i]+cnt);
        cnt+=1-(B[i]+cnt); 
      }
    } else{
      if (B[i]+cnt<0) continue;
      else{
        ans2+=B[i]+cnt-(-1);
        cnt-=(B[i]+cnt-(-1));
      }
    }
  }

  cout << min(ans1,ans2) << "\n";
  return 0;
}

Measured memory_bytes: 1792
local n,k=io.read("n","n")
local a={}
local m={}
for i=1,n do
    local input=io.read("n")
    a[i]=input
    m[input]=true
end

local dp={}
for i=0,k do
    if m[i] then
        dp[i]=true
    end
    for j=1,n do
        if not dp[i] then
            dp[i+a[j]]=true
        end
    end
end
print(dp[k] and "First" or "Second")

Measured memory_bytes: 8388
#include <iostream>

int main() {
  int a, b, i, j, x;
  
  std::cin >> a >> b;
  
  x = 0;
  
  while (a <= b) {
    i = a / 1000;
    j = a % 100;
    if(((i % 10) == (j / 10)) &&
       ((i / 10) == (j % 10))) x++;

    a++;
  }
  
  std::cout << x <<std::endl;
  
  return 0;
}


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

int nim[100005];
int a[102];

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

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

  nim[0] = 0;
  for (int i = 1; i <= k; i++) {
    vector<int> nims;
    for (int j = 0; j < n; j++) {
      if (a[j] <= i) nims.push_back(nim[i - a[j]]);
    }
    sort(nims.begin(), nims.end());
    nims.resize(unique(nims.begin(), nims.end()) - nims.begin());
    nim[i] = 0;
    while (nim[i] < nims.size() && nims[nim[i]] == nim[i]) nim[i]++;
  }
  cout << (nim[k] != 0 ? "First\n" : "Second\n");

  return 0;
}

Measured memory_bytes: 640
# -*- coding:utf8 -*-

l = list(map(str, input().split()))
s = []

def add(x, y):
    return x + y

def sub(x, y):
    return x - y

def mul(x, y):
    return x * y

for item in l:
    v = None
    if item == '+':
        v = add(s.pop(-1), s.pop(-1))
    elif item == '-':
        v = sub(s.pop(-2), s.pop(-1))
    elif item == '*':
        v = mul(s.pop(-1), s.pop(-1))
    else:
        v = int(item)
    s.append(v)
print(s[0])



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

using namespace std;
int S(int a){
    int ans=0;
    while(a)ans+=(a%10),a/=10;
    return ans;
}
int n,ans=300000;
int main()
{
    scanf("%d",&n);
    for(int a=1;a<n;++a){
        int b=n-a;
        ans = min(ans,S(b) + S(a));
    }
    cout << ans <<'\n';
    return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        tmp = (x-((500*i)+(100*j)))
#        print (i,j,tmp)
        if tmp == 0:
            ans += 1
        elif tmp > 0:
            if tmp%50 == 0 and tmp//50 <= c:
                ans += 1
        else:
            # tmp < 0
            pass            
print (ans)


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

int main(){
  int N,W;
  cin>>N>>W;
  int v[N],w[N];
  for(int i=0;i<N;i++){
    cin>>v[i]>>w[i];
  }
  int DP[N+1][W+1];
  for(int j=0;j<=W;j++){
    DP[0][j]=0;
  }
  for(int i=1;i<=N;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j]=DP[i-1][j];
      }
      else{
        if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
          DP[i][j]=DP[i-1][j];
        }
        else{
          DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout<<DP[N][W]<<endl;
}



Measured memory_bytes: 7028
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
using namespace std;
#define INF 1e15
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define END system("PAUSE");return 0
int n, k, a[111111];
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] >= k) {
			puts("Possible");
			for (int j = n - 1; j > i; j--) cout << j << endl;
			for (int j = 1; j <= i; j++)cout << j << endl;
			END;
		}
	}
	puts("Impossible");
	END;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define PB(a,i) (a).push_back(i)
#define ALL(a) (a).begin(),(a).end()
#define SIZE(a,n) (a).resize(n)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;


int main() {
	lli n, i, j, k;
	vector<lli>a, b;

	cin >> n;
	SIZE(a, n);
	SIZE(b, n);
	rep(i, n) {
		cin >> a[i];
	}
	b[0] = 0;
	repj(i, 1, n) {
		b[i] = (a[i - 1] - b[i - 1] / 2) * 2;
	}
	k = a[n - 1] - b[n - 1] / 2;
	rep(i, n) {
		if (i % 2 == 0)b[i] += k;
		else b[i] -= k;
		cout << b[i] << " ";
	}

	return 0;
}


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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;
ll a[200005] = {};
ll s[200005] = {};
int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> a[i];
		s[i] += a[i];
		if (i > 0) s[i] += s[i - 1];
	}

	ll min = 1000000001 * 2;
	REP(i, N - 1)
	{
		ll z = abs(s[i] - (s[N - 1] - s[i]));
		if (z < min)min = z;
	}

	cout << min << endl;
	return 0;
}

Measured memory_bytes: 3328
s = input()
t = input()
l = [0]*26
flag = 0
for i in range(len(s)):
    if l[ord(s[i])-ord("a")] == 0:
        if t[i] not in l:
            l[ord(s[i])-ord("a")] = t[i]
        else:
            flag = 1
            break
    else:
        if l[ord(s[i])-ord("a")] != t[i]:
            flag = 1
            break
if flag == 0:
    print("Yes")
else:
    print("No")

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

int main(void){
    int N;
    int X;
    int sum = 0;
    int min;
    double result;
    int kekka;

    

    scanf("%d %d",&N,&X);
    if(N < 2 || N > 100){
        return 0;
    }
    

    int m[101];

    for(int i = 0; i < N; i++){
        scanf("%d",&m[i]);
    }

	min = m[0];
    for(int i = 0; i < N; i++){
        if(m[i] <= min){
            min = m[i];
            //printf("%d\n",min);
        }
    }

    for(int i= 0;i < N; i++){
        sum = sum + m[i];
        //printf("%d\n",sum);
    }

    if(sum <= X){
       result = (X - sum) / min;
       //printf("%lf\n",result);
    }else{
        return 0;
    }
    kekka = (int)result + N;
     printf("%d\n",kekka);
    }

Measured memory_bytes: 128
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2 - 1])
        else:
            ret.append(sorted_x[n // 2])
for i in ret:
    print(i)


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

int cmp(const void*a,const void*b){
	return *(int*)b-*(int*)a;
}
int main(void){
	int N,K;
	scanf("%d%d",&N,&K);
	int l[N];
	for(int i=0;i<N;i++)scanf("%d",&l[i]);
	qsort(l,N,sizeof(int),cmp);
	int ans = 0;
	for(int i=0;i<K;i++)ans+=l[i];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
# 通過の種類は10の100乗 + 1 種類
# 10の(10の100乗)乗の桁数は10の100乗桁 (1グーゴル)
# 10の6乗 = 1000000 (100万)
# 通過の方が圧倒的に大きい

s = input()[::-1]  # 与えられた数を下の桁から見る
length = len(s)
dp = [[0]*2 for _ in range(length+1)]  # j=1を更新するとき、お釣りの部分を格納していることになる（支払った1枚の紙幣は次のタイムステップで更新される）
for i in range(length):
    # 今見ている桁に関して、ちょうど支払うとき
    dp[i+1][0] = min(dp[i][0]+int(s[i]), dp[i][1]+int(s[i])+1)

    # 今見ている桁に関して、1つ大きい桁の紙幣を1枚使って支払う
    if i != 0:
        # ここで格納される値はお釣りの部分と考えることができる
        dp[i+1][1] = min(dp[i][0]+10-int(s[i]), dp[i][1]+(10-1)-int(s[i]))
    else:
        dp[i+1][1] = dp[i][0]+10-int(s[i])  # お釣りの部分のみが格納されている

print(min(dp[length][0], dp[length][1]+1))


Measured memory_bytes: 140720
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int print(int num, char a, char b) {
    for(int i = 0; i < 50; i++) {
        for(int j = 0; j < 100; j++) {
            if (i%2 == 1 && j%2 == 0 && num>0) {
                num--;
                cout << a;
            } else {
                cout << b;
            }
        }
        cout << endl;
        // if (num == 0) break;
    }
}
int main() {
    int a, b;
    cin >> a >> b;
    cout << 100 << " " << 100 << endl;
    print(a-1, '.', '#');
    print(b-1, '#', '.');
    return 0;
}


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

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

using ll = long long;

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

int main() {
  ll N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  vector<vector<char>> vv(K);
  for(ll i = 0LL; i < N; i++) {
    char c;
    ll n;
    cin >> c;
    n = i % K;
    vv.at(n).push_back(c);
  }
  vector<ll> Tpoint(K,0);
  for(ll i = 0; i < K; i++) {
    int s = vv.at(i).size();
    vector<vector<ll>> point(3,vector<ll>(s+1));
    for(int j = 0; j < 3; j++) {
      point[j][0]=0;
    }
    for(int j = 1; j <= s; j++) {
      if(vv[i][j-1]=='r'){
        point[0][j]=max(point[1][j-1],point[2][j-1]);
        point[1][j]=max(point[0][j-1],point[2][j-1]);
        point[2][j]=max(point[0][j-1],point[1][j-1])+P;
      }
      if(vv[i][j-1]=='s'){
        point[0][j]=max(point[1][j-1],point[2][j-1])+R;
        point[1][j]=max(point[0][j-1],point[2][j-1]);
        point[2][j]=max(point[0][j-1],point[1][j-1]);
      }
      if(vv[i][j-1]=='p'){
        point[0][j]=max(point[1][j-1],point[2][j-1]);
        point[1][j]=max(point[0][j-1],point[2][j-1])+S;
        point[2][j]=max(point[0][j-1],point[1][j-1]);
      }
    }
    for(int j = 0; j < 3; j++) {
      chmax(Tpoint[i],point[j][s]);
    }
  }
  ll ans = 0LL;
  for(ll i =0LL; i < K; i++) {
    ans += Tpoint[i];
  }
  cout<<ans<<endl;
}
  

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

void solve(long long a, std::string s)
{
    cout << ((a >= 3200) ? s : "red") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long a;
    scanf("%lld", &a);
    std::string s;
    std::cin >> s;
    solve(a, s);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int paper[10][10];
  int x,y,q,i,j,count;
  int px,py;
  int max=0;
  int xplus[] = {0,0,-1,1,-1,-1,1,1,0,0,-2,2};
  int yplus[] = {-1,1,0,0,-1,1,-1,1,-2,2,0,0};

  for(j=0;j<10;j++){
    for(i=0;i<10;i++){
      paper[i][j]=0;
    }
  }


  while(scanf("%d,%d,%d",&x,&y,&q)!=EOF){
    paper[y][x]++;
    for(i=0;i<q*4;i++){
      px=x+xplus[i];
      py=y+yplus[i];
      if(px>=0&&px<10&&py>=0&&py<10){
	paper[py][px]++;
      }
    }
  }
  for(j=0;j<10;j++){
    for(i=0;i<10;i++){
      if(paper[j][i]==0){
	count++;
      }
      if(paper[j][i]>max){
	max=paper[j][i];
      }
    }
  }

  printf("%d\n",count);
  printf("%d\n",max);


  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner scan;
    int A;
    int B;
    int C;
    int K;
    int Aa;
    int Bb;
    int Cc;

    scan = new Scanner(System.in);
    A = scan.nextInt();
    B = scan.nextInt();
    C = scan.nextInt();
    K = scan.nextInt();

    if (K >= A){
        Aa = A;
        K = K - Aa;
        if (K == 0){
            System.out.println (1*Aa);
        }else{
            if ( K >= B){
                Bb = B;
                K = K - Bb;
                if (K == 0){
                    System.out.println(1*Aa + 0*Bb);
                }else {
                    if (K >= C){
                        Cc = C;
                        K = K - Cc ;
                        if(K == 0){
                            System.out.println(1*Aa + 0*Bb + (-1*Cc));
                        }else{
                            System.out.println(1*Aa + 0*K);
                        }
                        }else{
                            System.out.println(1*Aa + 0*Bb + (-1*K));
                        }
                    }
                }
                }
    }else{
        System.out.println(1*K);
        }

    }
}

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

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

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_November_30(void) {

	int M1, D1, M2, D2; cin >> M1 >> D1 >> M2 >> D2;

	cout << (M1 != M2 ? 1 : 0) << endl;
	return;
}

int main(void) {

	A_November_30();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
#define sign(a) ((a>0)-(a<0))
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define LL long long
#define INF (LL)(1LL<<60)
#define all(a) a.begin(), a.end()
#define gr greater<LL>()

using namespace std;

void solve(long long N, std::string S){
    vector<vector<int>> tab(N, vector<int>(N,0));
    for(LL i=0; i<N-1; i++){
        for(LL j=i+1; j<N; j++){
            if(S[i]==S[j])tab[i][j]++;
        }
    }
    
    LL ans = 0;
    for(LL j=1; j<N; j++){
        LL cnt=0;
        rep(i,N-j){
            if(tab[i][j+i] > 0){
                cnt++;
            }else{
                ans=max(ans,min(cnt,j));
                cnt=0;
            }
        }
        ans=max(ans,min(cnt,j));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S;
    cin >> S;
    ll N = S.size();
    string T = "";
    REP(i, N/2) T += "hi";
    cout << (T==S?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());

		if (A > X) {
			System.out.println("NO");
		} else if (A + B < X) {
			System.out.print("NO");
		} else {
			System.out.println("YES");
		}

	}

}

Measured memory_bytes: 24020
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines.shift() - 0;
    let Ln = lines[0].split(" ").map((v) => v - 0);
    Ln.sort((a, b) => b - a);
    let max = Ln.shift();
    let sum = Ln.reduce((ac, value, index, array) => ac + value, 0);

    console.log(max < sum ? "Yes" : "No");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> c(m);
  rep(i,m) cin >> c[i].first >> c[i].second;
  
  rep(x,1000) {
    int keta = 1;
    vector<int> d(1, x % 10);
    int xx = x / 10;
    while(xx) {
      keta++;
      d.push_back(xx % 10);
      xx /= 10;
    }
    reverse(d.begin(),d.end());
    
    if(keta != n) continue;
    bool ok = true;
    rep(i,m) {
      if(d[c[i].first - 1] != c[i].second) ok = false;
    }
    if(ok) {
      cout << x << endl;
      return 0;
    }  
  }
  cout << -1 << endl;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {

    val (n,k) = readLine()!!.split(" ").map{it.toInt()}

    var h = readLine()!!.split(" ").map{it.toInt()}
    var dp =  IntArray(n+1){ Int.MAX_VALUE}



    dp[0] = 0
    for(i in 1 until n){
        for(j in i-k until i){
            if(j > -1){
                dp[i] = Math.min(dp[i],dp[j] + Math.abs(h[i]-h[j]))
            }
        }

    }
    println(dp[n-1])

}


Measured memory_bytes: 51984
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[]a = new int[n];
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		Map <Integer,Integer> map = new HashMap<>();
		
		for(int i = 0; i < n; i++) {
			map.put(a[i], i+1); 
		}
		
		
		for(int i = 0; i < n; i++) {
			System.out.print(map.get(i+1)+" ");
		}
		
		
	}

}


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

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


int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    for (int i = 1; i <= (N / 2); i++){
        if(i != N - i){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())

min1 = 100
if min1 > a:    min1 = a
if min1 > b:    min1 = b
if min1 > c:    min1 = c
if min1 > d:    min1 = d

if e < f:   min2 = e
else:       min2 = f

print((a+b+c+d+e+f) - min1 - min2)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

string getIdWithCheckDegit(vector<vector<int>>& a, int id) {
	string s = to_string(id);
	while (s.size() != 4) s = '0' + s;

	int cur = 0;
	rep(i, 4) { cur = a[cur][s[i] - '0']; }
	s += cur + '0';
	return s;
}

vector<vector<int>> a(10, vector<int>(10));
bool check(string& s) {
	int cur = 0;
	rep(i, 5) { cur = a[cur][s[i] - '0']; }
	return cur == 0;
}

signed main() {
	rep(i, 10) {
		rep(j, 10) { cin >> a[i][j]; }
	}

	int cnt = 0;
	rep(i, 10000) {
		auto s = getIdWithCheckDegit(a, i);

		vector<string> miss;
		rep(i, 5) {
			for (char c = '0'; c <= '9'; c++) {
				if (s[i] == c) continue;
				string t = s;
				t[i] = c;
				miss.emplace_back(t);
			}
		}
		rep(i, 4) {
			if (s[i] == s[i + 1]) continue;
			string t = s;
			swap(t[i], t[i + 1]);
			miss.emplace_back(t);
		}

		if (any_of(all(miss), check)) { cnt++; }
	}
	cout << cnt << endl;
}



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

namespace ABC157A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if (N % 2 == 0)
            {
                Console.WriteLine(N / 2);
            }
            else
            {
                Console.WriteLine(N / 2 + 1);
            }
        }
    }
}


Measured memory_bytes: 27544
#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;
  vector<int> a(n), b(n), c(n-1);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];


  int ans = 0;
  int prevI = 0;
  rep(i,n) {    
    ans += b[a[i]-1];
    if (prevI+1 == a[i]) ans += c[a[i]-2];
    prevI = a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
vector<int> g[26];
bool used[26];
int in[26];
int out[26];

void dfs(int curr) {
  used[curr] = true;
  for (int next : g[curr]) {
    if (!used[next]) dfs(next);
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  while (cin >> n, n) {
    for (int i = 0; i < 26; i++) {
      g[i].clear();
      used[i] = false;
      in[i] = out[i] = 0;
    }
    string s;
    int org;
    for (int i = 0; i < n; i++) {
      cin >> s;
      int from = s.front() - 'a', to = s.back() - 'a';
      org = from;
      g[from].emplace_back(to);
      in[to]++;
      out[from]++;
    }
    dfs(org);
    bool ok = true;
    for (int i = 0; i < 26; i++) {
      if (in[i] == 0 && out[i] == 0) continue;
      ok &= (used[i] && in[i] == out[i]);
    }
    cout << (ok ? "OK" : "NG") << endl;
  }

  return 0;
}


Measured memory_bytes: 3184
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		
			while(sc.hasNext())
			{
				int count = 0;
				int n = sc.nextInt();
					for(int i = 0; i < 10; i++)
					{
						for(int j = 0; j < 10; j++)
						{
							for(int k = 0; k < 10; k++)
							{
								for(int l = 0; l < 10; l++)
								{
									if(i + j + k + l == n)count++;
								}
							}
						}
					}
				System.out.println(count);
			}
	}
}

Measured memory_bytes: 18852
def bubbleSort(array):
    n = len(array)
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in range(n-1, 0, -1):
            if array[i-1] > array[i]:
                array[i-1], array[i] = array[i], array[i-1]
                flag = True
                cnt += 1
    return (array, cnt)

n = int(input())
array = [int(x) for x in input().split()]

resultArray, cnt = bubbleSort(array)

print(*resultArray)
print(cnt)


Measured memory_bytes: 5612
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	for(int i = 1; i <= min(n, 50000); ++i)
	{
		int x = floor(i * 1.08);
		if(x == n) return cout << i << '\n', 0;
	}
	cout << ":(\n";
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
    int n;
    int temp;
    int a = 0;
    set<int> s;

    cin >> n;

    for(int i = 0; i < n; i++){
      cin >> temp;
      s.insert(temp);
    }

    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256