akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n=s.size();
    int ans=0;
    rep(i,n){
        if (s[i]=='+') ans++;
        if (s[i]=='-') ans--;
    }
    cout<<ans<<"\n";
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = vs[0];
            int K = vs[1];
            int Q = vs[2];
            int[] sum = new int[N];
            for (int i = 0; i < Q; i++) {
                int a = int.Parse(Console.ReadLine());
                sum[a - 1]++;
            }
            for (int i = 0; i < N; i++) {
                int point = K - (Q - sum[i]);
                if (point > 0) {
                    Console.WriteLine("Yes");
                } else {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 17884
#include <stdio.h>
#include <string.h>
int main()
{
	char a[200005];
	char b[200005];
	scanf("%s",&a);
	scanf("%s",&b);
	int n,m=0,i,j;
	n=strlen(a);
	for(i=0;i<n;i++){
		if(a[i]!=b[i]){
			m++;
		}
	}
	printf("%d\n",m);
  return 0;
}
  

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1001001001;

const int mod = 1000000007;

int main() {

    int n, a, b;

    cin >> n >> a >> b;

    cout << min(n * a, b) << endl;

}



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

int main()
{
    int a,i,c=0;
    cin>>a;
    int b[a];
    for(i = 0; i < a; i++)
    {
        cin>>b[i];
        if(b[i]%2==0 && (b[i]%3!=0 && b[i]%5!=0))
        {
            c=1;
        }

    }
    if(c==1)
        cout<<"DENIED\n";
    else
        cout<<"APPROVED\n";

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int mod = 1000000007;

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
void ini_func(vector<ll>& a, vector<ll>& b,ll N) {
	ll k, c;
	for (ll i = 0; i < N; i++) {
		cin >> k >> c;
		a.push_back(k);
		b.push_back(c);
	}


}
int num[6]= { 105,135,165,189,195,201};
int main() {
	string S;
	cin >> S;
	ll K;
	cin >> K;
	for (ll i = 0;i<S.size(); i++) {
		if ((int)S[i] >= 50||i+1==K) {

			cout << S[i];
			return 0;
		}
	}



	
}

Measured memory_bytes: 256
//Reconstruction of a Tree
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, pos;
vector<int> pre, in, post;

void solve(int l, int r) {
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    solve(l, m);
    solve(m+1, r);
    post.push_back(root);
}

int main() {
    cin >> n;

    int k;
    for(int i=0; i<n; i++) {
        cin >> k;
        pre.push_back(k);
    }
    for(int i=0; i<n; i++) {
        cin >> k;
        in.push_back(k);
    }

    pos = 0;
    solve(0, n);

    for(int i=0; i<n-1; i++) cout << post[i] << " ";
    cout << post[n-1] << endl;
}


Measured memory_bytes: 3140
import std.stdio;
import std.string;
import std.format;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.concurrency;
import std.traits;
import std.uni;
import std.regex;
import core.bitop : popcnt;
alias Generator = std.concurrency.Generator;

enum long INF = long.max/5;
enum long MOD = 10L^^9+7;

void main() {
  long N;
  scanln(N);
  writeln(N.ceil(2));
}

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


void times(alias fun)(long n) {
  // n.iota.each!(i => fun());
  foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(long n) {
  // return n.iota.map!(i => fun()).array;
  T[] res = new T[n];
  foreach(ref e; res) e = fun();
  return res;
}

T ceil(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  // `(x+y-1)/y` will only work for positive numbers ...
  T t = x / y;
  if (y > 0 && t * y < x) t++;
  if (y < 0 && t * y > x) t++;
  return t;
}

T floor(T)(T x, T y) if (isIntegral!T || is(T == BigInt)) {
  T t = x / y;
  if (y > 0 && t * y > x) t--;
  if (y < 0 && t * y < x) t--;
  return t;
}

ref T ch(alias fun, T, S...)(ref T lhs, S rhs) {
  return lhs = fun(lhs, rhs);
}
unittest {
  long x = 1000;
  x.ch!min(2000);
  assert(x == 1000);
  x.ch!min(3, 2, 1);
  assert(x == 1);
  x.ch!max(100).ch!min(1000); // clamp
  assert(x == 100);
  x.ch!max(0).ch!min(10); // clamp
  assert(x == 10);
}

mixin template Constructor() {
  import std.traits : FieldNameTuple;
  this(Args...)(Args args) {
    // static foreach(i, v; args) {
    foreach(i, v; args) {
      mixin("this." ~ FieldNameTuple!(typeof(this))[i]) = v;
    }
  }
}

void scanln(Args...)(auto ref Args args) {
  enum sep = " ";
  enum n = Args.length;
  enum fmt = n.rep!(()=>"%s").join(sep);

  string line = readln.chomp;
  static if (__VERSION__ >= 2074) {
    line.formattedRead!fmt(args);
  } else {
    enum argsTemp = n.iota.map!(
      i => "&args[%d]".format(i)
    ).join(", ");
    mixin(
      "line.formattedRead(fmt, " ~ argsTemp ~ ");"
    );
  }
}

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
  template fold(fun...) if (fun.length >= 1) {
    auto fold(R, S...)(R r, S seed) {
      static if (S.length < 2) {
        return reduce!fun(seed, r);
      } else {
        return reduce!fun(tuple(seed), r);
      }
    }
  }
}

// popcnt with ulongs was added in D 2.071.0
static if (__VERSION__ < 2071) {
  ulong popcnt(ulong x) {
    x = (x & 0x5555555555555555L) + (x>> 1 & 0x5555555555555555L);
    x = (x & 0x3333333333333333L) + (x>> 2 & 0x3333333333333333L);
    x = (x & 0x0f0f0f0f0f0f0f0fL) + (x>> 4 & 0x0f0f0f0f0f0f0f0fL);
    x = (x & 0x00ff00ff00ff00ffL) + (x>> 8 & 0x00ff00ff00ff00ffL);
    x = (x & 0x0000ffff0000ffffL) + (x>>16 & 0x0000ffff0000ffffL);
    x = (x & 0x00000000ffffffffL) + (x>>32 & 0x00000000ffffffffL);
    return x;
  }
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

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

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

let main() =
    let [| N; M |] = reada int
    let bs = Array.init N (fun _ -> 1)
    let red = Array.zeroCreate N
    red.[0] <- true
    for i in 0 .. M - 1 do
        let [| x; y |] = reada int
        let x, y = x - 1, y - 1
        bs.[x] <- bs.[x] - 1
        bs.[y] <- bs.[y] + 1
        if red.[x] then red.[y] <- true
        if bs.[x] = 0 then red.[x] <- false

    red
    |> Array.filter id
    |> Array.length
    |> puts
    ()

// -----------------------------------------------------------------------------------------------------
main()
writer.Dispose()


Measured memory_bytes: 17424
#include<bits/stdc++.h>
#define        ll          long long int
#define        sz          2010
#define        fast        ios_base :: sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define        sc1(a)      scanf("%lld",&a)
#define        sc2(a,b)    scanf("%lld %lld",&a,&b)
#define        pb          push_back
#define        pn          printf("No\n")
#define        pyy          printf("Yes\n")
#define        op(a)       printf("%lld\n",a)

using namespace std;


int main()
{
    ll k;
    cin>>k;
    while(k--)
    {
        cout<<"ACL";
    }
    return 0;
}


Measured memory_bytes: 3592
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::ops::Bound::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout]
fn main() {
    input! {
        n: usize, q: usize,
        a: [usize; n],
        query: [(usize, usize, usize); q]
    }

    let mut bit = BIT::new(n);
    for (i, a) in (0..).zip(a) {
        bit.add(i + 1, a);
    }

    for (command, x, y) in query {
        if command == 0 {
            bit.add(x + 1, y);
        } else {
            let res = bit.sum(y) - bit.sum(x);
            println!("{}", res);
        }
    }
}

#[allow(dead_code)]
/// Binary Indexed Tree of usize
pub struct BIT {
    buf: Vec<usize>,
}
#[allow(dead_code)]
impl BIT {
    pub fn new(n: usize) -> BIT {
        BIT {
            buf: vec![0; n + 1],
        }
    }
    pub fn sum(&self, i: usize) -> usize {
        let mut i = i;
        let mut s = 0;
        while i > 0 {
            s += self.buf[i];
            i &= i - 1;
        }
        s
    }
    pub fn add(&mut self, i: usize, x: usize) {
        let mut i = i as i64;
        while i < self.buf.len() as i64 {
            self.buf[i as usize] += x;
            i += i & -i;
        }
    }
}

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

int main() {
  int n, s1, s2, ms = INT_MAX;
  cin >> n;
  int w[n];
  REP(i, n) cin >> w[i];

  for (int t = 1; t < n; ++t) {
    s1 = 0;
    s2 = 0;
    REP(i, n) {
      if (i <= t) s1 += w[i];
      else s2 += w[i];
    }
    ms = min(abs(s1 - s2), ms);
  }
  cout << ms << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



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

  cout << a[0] << b[1] << c[2] << endl;


  return 0;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();


		int lengthX = x1 - x2;
		int lengthY = y1 -y2;


		int x3 = x2 + lengthY;
		int y3 = y2 - lengthX;

		int x4 = x1 + lengthY;
		int y4 = y1 - lengthX;

		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}

}


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

ll solve() {
    ll N, K, a;
    cin >> N >> K;
    ll M = 200000;
    vector<ll> b(M);
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        a--;
        b[a]++;
    }
    sort(b.begin(), b.end(),greater<>());
    ll ans = 0;
    for ( int i = K; i < M; i++ ) {
        ans += b[i];
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, m; cin>>n>>m;
  vi c(n+1);
  rep(i,0,m) {
    int x, y; cin>>x>>y;
    c[x]++;
    c[y]++;
  }
  rep(i,1,n+1) {
    if(c[i] % 2) {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SP << " " <<
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> L(N);
  int tmp = -1;
  REP(i, N) {
    if(A[i] > tmp) tmp = A[i];
    L[i] = tmp;
  }
  vector<int> R(N);
  tmp = -1;
  REP(i, N) {
    if(A[N - i - 1] > tmp) tmp = A[N - i - 1];
    R[N - i - 1] = tmp;
  }
  cout << R[1] << endl;
  for(int i = 1; i < N - 1; i++) {
    cout << max(L[i - 1], R[i + 1]) << endl;
  }
  cout << L[N - 2] << endl;

  return 0;
}

Measured memory_bytes: 6272
import java.util.Scanner;

	public class Main {

		public static void main(String[] args) {
			// AtCoder_C
			Scanner sc = new Scanner(System.in);
			int ans = 0;

			int N = sc.nextInt();
			long now = sc.nextLong();
			long next = 0;

			int moveNow = 0;
			int moveMax = 0;

			for(int i=1; i<N; i++) {
				next = sc.nextLong();
				if(now >= next) {
					moveNow++;
				} else {
					if(moveMax < moveNow) {
						moveMax = moveNow;
					}
					moveNow = 0;
				}
				now = next;
			}

			if(moveMax < moveNow) {
				moveMax = moveNow;
			}

			System.out.println(moveMax);

    	    // Scannerクラスのインスタンスをクローズ
    		sc.close();
    	}
    }

Measured memory_bytes: 60012
from functools import reduce
from itertools import accumulate,chain
def rerooting(N, adj, merge, identity, finalize):
    """
    merge: (T,T) -> T, (T, merge)はモノイド
    identity: 単位元
    finalize: T -> T

    以下の形で書けるdpは対応可能
    dp[u,v] = finalize(merge(dp[v,k] for k in adj[v] if k != u))
    ただし(u,v)は辺
    """

    order = [None]*N
    parent = [None]*N
    parent[0] = -1
    stack = [0]
    for i in range(N):
        v = stack.pop()
        order[i] = v
        for u in adj[v]:
            if parent[u] is None:
                parent[u] = v
                stack.append(u)

    # from leaf to parent
    dp_down = [None]*N
    for v in reversed(order[1:]):
        p = parent[v]
        dp_down[v] = finalize(reduce(merge,
            (dp_down[c] for c in adj[v] if c != p),
            identity))

    # from parent to leaf
    dp_up = [None]*N
    dp_up[0] = identity
    for v in order:
        p = parent[v]
        if len(adj[v]) == 1 and adj[v][0] == p:
            continue
        left = tuple(accumulate(
            chain((dp_up[v],),(dp_down[u] for u in adj[v] if u != p)),
            merge))
        right = tuple(accumulate(
            chain((identity,),(dp_down[u] for u in reversed(adj[v]) if u != p)),
            merge))
        i = 0
        for u in adj[v]:
            if u != p:
                dp_up[u] = finalize(merge(left[i],right[-i-2]))
                i += 1

    for v,l in enumerate(adj):
        order[v] = reduce(merge,
                    (dp_down[u] for u in adj[v] if u != parent[v]),
                    identity)
        order[v] = finalize(merge(order[v], dp_up[v]))

    return order

def solve(N,M,E):

    adj = [[] for _ in range(N)]
    for a,b in E:
        adj[a].append(b)
        adj[b].append(a)

    def merge(x,y):
        return (x*y)%M
    def finalize(x):
        return x+1

    res = rerooting(N,adj,merge,1,finalize)
    return [v-1 for v in res]


if __name__ == '__main__':
    N,M = map(int,input().split())
    E = [tuple(map(lambda x: int(x)-1, input().split())) for _ in range(N-1)]
    print(*solve(N,M,E),sep='\n')

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

int main(){
  string S;
  cin >> S;
  int a=0;
  int b=0;
  int c=0;
  for(int i=0;i<S.size();i++){
    switch(S.at(i)){
      case 'a':
      a++;
      break;
      case 'b':
      b++;
      break;
      case 'c':
      c++;
      break;
    }
  }
  if(max({a,b,c})-min({a,b,c})<=1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll MOD = (ll)(1000 * 1000 * 1000 + 7);
const int SIZE = 1000000;
//const int SIZE = 1000;                                     
ll inv[SIZE];
ll fac[SIZE];
ll facinv[SIZE];

void init() {
  inv[1] = 1;
  for(int i = 2; i < SIZE; i++) {
    inv[i] = MOD - (MOD / i) * inv[(int)MOD % i] % MOD;
  }
  fac[0] = facinv[0] = 1;
  for(int i = 1; i < SIZE; i++) {
    fac[i] = (fac[i-1] * (ll)i) % MOD;
    facinv[i] = (facinv[i-1] * inv[i]) % MOD;
  }
}

inline ll P(int a, int b) {
  return fac[a] *  facinv[a-b] % MOD;
}

inline ll C(int a, int b) {
  return (fac[a] * facinv[b] % MOD) * facinv[a-b] % MOD;
}

inline ll H(int a, int b) {
  return C(a+b-1,b);
}


int main() {
  init();
  int N, M;
  cin >> N >> M;
  vector<int> num;
  int rem = M;
  for(int i = 2; i <= rem; i++) {
    if(rem % i == 0) {
      int cnt = 0;
      while(rem % i == 0) {
        rem /= i;
        cnt++;
      }
      num.push_back(cnt);
    }
  }
  ll ans = 1LL;
  for(int i = 0; i < num.size(); i++) {
    int n = num[i];
    ans = (ans * H(N, n)) % MOD;
    //    cout << i << " " << n << " " << ans << endl;       
  }
  //  cout << "Answer=";                                     
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int len = s.length(), i = 0;
	bool flag = false;
	while (i < len) {
		if (s == t) {
			flag = true;
			break;
		}
		char c = s[0];
		s.erase(0, 1);
		s += c;
		// cout << s << endl;
		i++;
	}
	if (flag) cout << "Yes";
	else {
		cout << "No";
	}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;



signed main(){
	cout<<fixed<<setprecision(10);
	
	int dy[5] = {-1,0,1,0};
	int dx[5] = {0,1,0,-1};	
	
	while(true) {
		int w, h, ans = -1;
		vector<int> C(4);
		vector<vector<int>> s;
		vector<vector<vector<int>>>dis;
		priority_queue<pair<pair<int,int>,pair<int,int>>, vector<pair<pair<int,int>,pair<int,int>>>, greater<pair<pair<int,int>,pair<int,int>>>> Q;
		
		cin>>w>>h;
		
		if(!w && !h) break;
		
		s.resize(h, vector<int>(w));
		dis.resize(4, vector<vector<int>>(h, vector<int>(w, INF)));
		
		dis[1][0][0] = 0;
		Q.push({{0,1},{0,0}});

		for(int i = 0; i < h; i++){
			for(int j = 0; j < w; j++){
				cin>>s[i][j];
			}
		}
		
		for(int i = 0; i < 4; i++){
			cin>>C[i];
		}
		
		while(Q.size()){
			pair<pair<int,int>,pair<int,int>> P = Q.top(); Q.pop();
			int c = P.first.first;
			int d = P.first.second;
			int y = P.second.first;
			int x = P.second.second;
			
			if(dis[d][y][x] < c) continue;
			
			if(y == h - 1 && x == w - 1) {
				ans = c;
				break;
			}			
			
			for(int i = 0; i < 4; i++){
				int nc = c + (!(s[y][x] == i)) * C[i];
				int nd = (d + i) % 4;
				int ny = y + dy[nd], nx = x + dx[nd];
				
				if(ny >= h || ny < 0 || nx >= w || nx < 0) continue;
				
				if(dis[nd][ny][nx] <= nc) continue;
				
				dis[nd][ny][nx] = nc;
				
				Q.push({{nc, nd},{ny, nx}});
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3292
/*
author: Apoorv Singh
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
 
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
#define pb push_back   
#define all(c) c.begin(), c.end()
#define For(i, a, b) for (long long i = a; i < b; ++i)
#define Forr(i, a, b) for (long long i = a; i > b; --i)
#define um unordered_map
#define F first
#define S second
#define ll long long 
#define endl "\n"
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;    
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

template <class X>
void printarr(X arr[], int n) 
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << ' ';
    cout << endl;
}
 
template <class T, class cmp = less<T>> using ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
 
ll modulo = 1e9 + 7;

ll fpow(ll a, ll n) 
{
    ll ans = 1;
    while (n) 
    {
        if (n&1) ans = (ans*a)%modulo;
        a = (a*a)%modulo; n = n >> 1;
    }
    return ans;
}

void solve() 
{
    int n,k; cin >> n >> k;
    int ans = 0;
    while (n)
    {
        ++ans;
        n /= k;
    }    
    cout << ans << endl;
}

int main() 
{
    fast_io();
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    byte a = sc.nextByte();
    short b = sc.nextShort();
    if(a>=10){
      System.out.println(b);
    }else{
      System.out.println(b+(10-a)*100);
    }
  }
}

Measured memory_bytes: 22356
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18
double len(int x1,int x2,int y1,int y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}
int main(){
	int N;
	cin>>N;
	vector<int> x(N),y(N);
	REP(i,N) cin>>x[i]>>y[i];
	vector<int> n(N);
	REP(i,N) n[i]=i;
	double sum=0;
	ll times=0;
	do{
		REP(i,N-1){
			//cout<<n[i]<<" ";
			sum+=len(x[n[i]],x[n[i+1]],y[n[i]],y[n[i+1]]);
		}
		//cout<<n[N-1]<<" ";
		//cout<<endl;
		times++;
	}while(next_permutation(n.begin(),n.end()));
	sum/=times;
	printf("%.10lf",sum);
	return 0;
}


Measured memory_bytes: 256
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,k = MAP()
h = [INT() for _ in range(n)]
h.sort()
print(min(h[i+k-1]-h[i] for i in range(n-k+1)))

Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	int n, k;
	
	cin >> n >> k;
	vector<int> h(n);
	int max = INF;
	for (int i = 0; i < n; i++) {
		cin >> h.at(i);
	}
	sort(h.begin(), h.end());
	for (int i = 0; i < n - k+1; i++) {
		if (h.at(k-1 + i) - h.at(i) < max) {
			max = h.at(k + i-1) - h.at(i);
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 3756
#pragma GCC optimize("Ofast")
  
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <cassert>
#include <numeric>
#include <math.h>
#include <bitset>
#include <random>
#include <regex>

using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,f,n) for(int i=f;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
constexpr int dy[] = {0,1,0,-1,1,-1,-1,1};
constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class A, class B> inline A updiv(const A a,const B b){ return (a + b - 1) / b; }
template <class A, class B> inline A gcd(const A a,const B b){ return b ? gcd(b,a % b) : a; }
template <class A, class B> inline A lcm(const A a,const B b){ return a / gcd(a,b) * b; }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;

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

    int n, m;
    cin >> n >> m;

    vector<vector<int> > g(n+1);

    rep(i,m){
        int a, b;
        cin >> a >> b;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }

    queue<int> que;
    vector<int> dist(n+1, INF), res(n+1);

    que.emplace(1);
    dist[1] = 0;

    while(!que.empty()){
        int now = que.front();
        que.pop();
        for(auto e : g[now]){
            if(chmin(dist[e], dist[now] + 1)){
                res[e] = now;
                que.emplace(e);
            }
        }
    }

    cout << "Yes\n";
    reps(i, 2, n){
        cout << res[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
int n, s[100005];
int main() {
    // freopen("data.txt", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &s[i]);
    long long ans = 0;
    for (int d = 1; d < n; ++d) {
        long long sum = 0;
        for (int k = 1; (k + 1) * d < n - 1; ++k) {
            if (k * d >= n - 1 - k * d && (n - 1) % d == 0) break;
            sum += 1LL * s[k * d];
            sum += 1LL * s[n - 1 - k * d];
            ans = max(ans, sum);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		Integer[] length = new Integer[3];

		for (int i = 0; i < length.length; i++) {
			length[i] = Integer.parseInt(scanner.next());
		}

		System.out.println(length[0] * length[1] / 2);

		scanner.close();
	}

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i,start,end) for(int i=start; i < end ; ++i)
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 10000000


int main()
{
	int n;
	cin>>n;
	if(n)
        cout<<0;
    else
        cout<<1;

}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;

int main() {
    cin>>N;
    vec s(N);
    rep(i,N) cin>>s[i];
    ll ans = 0;
    reps(i,1,N){//i = A-B
        ll lsum = 0, rsum = 0;
        reps(j,1,N/i){
            ll index = i*j, rindex = (N-1) - i*j;
            if(((N-1)%i == 0) && (index*2 >= N-1)) break;
            lsum += s.at(index);
            rsum += s.at(rindex);
            /*if(ans < lsum + rsum){
                cout<<i<<' '<<j<<' '<<lsum<<' '<<rsum<<endl;
            }*/
            ans = max(ans,lsum+rsum);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring> 
#include<vector>
#include<algorithm>
#define maxn 2020
using namespace std;
int n,l[maxn],r[maxn];
char a[maxn],b[maxn];
void init(){
	scanf("%s",a);
	scanf("%s",b);
	n=strlen(a);
	for(int i=0;i<n;++i)a[i]-='0',b[i]-='0';
}
struct node{int l,r;};
vector<node>tmp;
inline bool cmp(const node &a,const node &b){return a.l>b.l;}
inline int movel(int x){
	int sum=0;
	for(int i=0;i<n;++i)if(b[i]&&(!a[(i+x)%n]))++sum;
	for(int i=0;i<n;++i)if((!b[i])&&a[(i+x)%n])++sum;
	tmp.clear();
	for(int i=0;i<n;++i)
	if((!b[((i-x)%n+n)%n])&&a[i]&&(l[i]>x))tmp.push_back((node){l[i]-x,r[i]});
	if(!tmp.size())return sum;
	sort(tmp.begin(),tmp.end(),cmp);
	int nowl=tmp[0].l,mxr=0,ans=sum+nowl*2;
	for(int i=1;i<tmp.size();++i){
		mxr=max(mxr,tmp[i-1].r);
		nowl=tmp[i].l;
		ans=min(ans,sum+(nowl+mxr)*2);
	}
	mxr=max(mxr,tmp.back().r);
	ans=min(ans,sum+mxr*2);
	return ans;
}
inline int mover(int x){
	int sum=0;
	for(int i=0;i<n;++i)if(b[i]&&(!a[((i-x)%n+n)%n]))++sum;
	for(int i=0;i<n;++i)if((!b[i])&&a[((i-x)%n+n)%n])++sum;
	tmp.clear();
	for(int i=0;i<n;++i)
	if((!b[(i+x)%n])&&a[i]&&(r[i]>x))tmp.push_back((node){l[i],r[i]-x});
	if(!tmp.size())return sum;
	sort(tmp.begin(),tmp.end(),cmp);
	int nowl=tmp[0].l,mxr=0,ans=sum+nowl*2;
	for(int i=1;i<tmp.size();++i){
		mxr=max(mxr,tmp[i-1].r);
		nowl=tmp[i].l;
		ans=min(ans,sum+(nowl+mxr)*2);
	}
	mxr=max(mxr,tmp.back().r);
	ans=min(ans,sum+mxr*2);
	return ans;
}
void solve(){
	bool p=0;
	for(int i=0;i<n;++i)p|=b[i];
	if(!p){
		for(int i=0;i<n;++i)p|=a[i];
		if(p)puts("-1");else puts("0");
		return;
	}
	for(int i=0;i<n;++i)
	if(a[i]){
		int x=0;
		while(!b[((i-x)%n+n)%n])++x;
		l[i]=x;
		x=0;
		while(!b[(i+x)%n])++x;
		r[i]=x;
	}
	int ans=1000000000;
	for(int i=0;i<n;++i)ans=min(ans,i+movel(i));
	for(int i=0;i<n;++i)ans=min(ans,i+mover(i));
	printf("%d\n",ans);
} 
int main(){
	init();
	solve();
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	var X, Y int
	moneyA := 0
	if _, err := fmt.Scan(&X, &Y); err != nil {
		os.Exit(-1)
	}
	add(&moneyA, X)
	add(&moneyA, Y)
	if X == 1 && Y == 1 {
		moneyA += 400000
	}
	fmt.Println(moneyA)
}

func add(moneyA *int, A int) {
	switch A {
	case 1:
		*moneyA += 300000
	case 2:
		*moneyA += 200000
	case 3:
		*moneyA += 100000
	}
}


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

int main(){
    int n; cin >> n;
    int sum=0, maxL=0;
    rep(i,n){
        int L; cin >> L;
        sum+=L;
        maxL=max(maxL,L);
    }
    if(sum-maxL>maxL) cout << "Yes";
    else cout << "No";
}

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

vector<int> color(200,0);
vector<vector<int>> a(200);
bool BipartiteGraph (int v,int c){
    color[v]=c;
    rep(i,a[v].size()){
        if (color[a[v][i]]==c){
            return false;
        }
        else if (color[a[v][i]]==0&&!BipartiteGraph(a[v][i],-c)){
            return false;
        }
    }
    return true;
}

int main(){
    int N;cin>>N;
    int info[N][N];
    rep(i,N){
        string S;cin>>S;
        rep(j,N){
            info[i][j]=S[j]-48;
        }
    }
    rep(i,N){
        rep(j,N){
            if(info[i][j])a[i].push_back(j);
        }
    }

    if(!(BipartiteGraph(0,1)))cout<<-1<<endl;
    else{ //warshall_floyd
        rep(i,N){
            rep(j,N){
                if(i!=j and info[i][j]==0)info[i][j]=INF;
            }
        }
        rep(k,N){
            rep(i,N){
                rep(j,N){
                    if(info[i][k]==INF or info[k][j]==INF)continue;
                    info[i][j]=min(info[i][j],info[i][k]+info[k][j]);
                }
            }
        }
        int ans=0;
        rep(i,N){
            rep(j,N){
                ans=max(ans,info[i][j]);
            }
        }
        cout<<ans+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int k = in.readInt();
		
		int lol = 1; 
		for(int i = 0; i<n; i++) {
		  if(lol*2 < lol+k)
			  lol = lol*2; 
		  else lol = lol + k; 	
		}
		System.out.println(lol);
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 22228
/*
  Vivek Rathi
  CSE 3rd Year
  MNNIT
  THUMB RULE - THINK FOR DP FIRST AND THEN GREEDY!!!
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define sz(x)	(ll)x.size()
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#define endl '\n'
//unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//shuffle (foo.begin(), foo.end(), std::default_random_engine(seed));
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above-----------------------------------------------

int main()
{
	boost
	map<string,ll> m;
	ll t;
	cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<endl;
	cout<<"WA x "<<m["WA"]<<endl;
	cout<<"TLE x "<<m["TLE"]<<endl;
	cout<<"RE x "<<m["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a ;
    if(a<1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,s,z;
	int ans;
	cin>>k>>s;
	for(int x=0;x<=k;x++)
	{
		for(int y=0;y<=k;y++){
			z=s-(x+y);
			if(z>=0 && z<=k && x+y+z==s){
				ans++;
			}
		}
		}
		cout<<ans;
		
}

Measured memory_bytes: 256
def dist(a, b, x, y, h):
    return h + abs(a - x) + abs(b - y)

N = int(input())
P = []
for i in range(N):
    x, y, h = map(int, input().split())
    P.append([h, x, y])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(i, j, P[0][1], P[0][2], P[0][0])
        for p in P[1:]:
            if max(H - abs(p[1] - i) - abs(p[2] - j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

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

int main() {
  char a;
  cin >> a;
  if (a == 'A') {
    cout << 'T' << endl;
  }
  if (a == 'T') {
    cout << 'A' << endl;
  }
  if (a == 'G') {
    cout << 'C' << endl;
  }
  if (a == 'C') {
    cout << 'G' << endl;
  }
}


Measured memory_bytes: 256
import heapq


def main():
    n = int(input())
    As = sorted(list(map(int, input().split())))[::-1]
    ans = 0
    q = []
    heapq.heappush(q, -As[0])
    for i in range(1, n):
        tmp = -heapq.heappop(q)
        ans += tmp
        heapq.heappush(q, -As[i])
        heapq.heappush(q, -As[i])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31592
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define rep(i,a) for(int i=0;i<a;i++)
#define repa(i,a,b) for(int i=a;i<b;i++)
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii std::vector<pair<ll,ll> >
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define sz(a) (ll)(a.size())
#define flush(a) memset(a,0,sizeof(a))
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll a[200050][13]={0};
ll modu(ll x,ll n)
{
	return (x%n+n)%n;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,n,m,k,q,temp,x,y;
    // cin>>t;
    // while(t--)
    {
        ll count=0;
        bool flag=0;
        
        string s;
        cin>>s;
        n=s.length();
        ll ans=0;
        y=10;
        if(s[n-1]=='?')
        {
        	for(i=0;i<10;i++)
        	{
        		a[n-1][i]=1;
        	}
        }
        else
        {
        	x=s[n-1]-'0';
        	a[n-1][x]=1;
        }
        for(i=n-2;i>=0;i--)
        {
        	if(s[i]!='?')
        	{
        		x=s[i]-'0';
        		x*=y;
        		x%=13;
        		for(j=0;j<13;j++)
        		{	
        			a[i][(j+x)%13]+=(a[i+1][j])%mod;
        			a[i][(j+x)%13]%=mod;
        		}
        	}
        	else
        	{
        		for(j=0;j<10;j++)
        		{
        			x=j;
        			x*=y;
        			x%=13;
        			for(k=0;k<13;k++)
        			{
        				a[i][(x+k)%13]+=(a[i+1][k])%mod;
        				a[i][(k+x)%13]%=mod;
        			}
        		}
        	}
        	y*=10;
        	y%=13;
        }
        // for(j=0;j<s.length();j++)
        // {
        // 	for(i=0;i<13;i++)
        // 	{
        // 		cout<<a[j][i]<<" ";
        // 	}
        // 	cout<<endl;
        // }
      //   if(n!=1&&s[n-1]=='?')
      //   {
      //   	for(i=0;i<10;i++)
      //   	{
      //   		x=i*4;
      //   		x%=13;
      //   		ans+=(a[n-2][modu(5-x,13)]);
      //   		ans%=mod;
      //   	}
      //   }
      //   else if(n!=1)
      //   {
      //   	x=s[n-1]-'0';
      //   	x*=4;
    		// x%=13;
    		// ans+=(a[n-2][modu(5-x,13)]);
    		// ans%=mod;
      //   }
      //   else
      //   	ans=1;
        cout<<a[0][5]<<endl;
    }
    return 0;
}


Measured memory_bytes: 10704
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

static int cnt;

void insertion_sort(int a[], int n, int gap) {
    int i, j, v;
    for (i = gap; i < n; i++) {
        v = a[i];
        j = i - gap;
        while (j >= 0 && a[j] > v) {
            a[j + gap] = a[j];
            j = j - gap;
            cnt++;
        }
        a[j + gap] = v;
    }
}

void shell_sort(int a[], int n) {
    int m, i;
    int gaps[100];
    gaps[0] = 0;
    for (i = 1; i <= n; i++) {
        gaps[i] = 3 * gaps[i-1] + 1;
        if (gaps[i] >= n / 3) {
            m = i;
            break;
        }
    }
    cnt = 0;
    printf("%d\n", m);
    for (i = 0; i < m; i++) {
        if (i == 0)
            printf("%d", gaps[m-i]);
        else
            printf(" %d", gaps[m-i]);
        insertion_sort(a, n, gaps[m-i]);
    }
    printf("\n");
    printf("%d\n", cnt);
    for (i = 0; i < n; i++) {
        printf("%d\n", a[i]);
    }
}

int main(void) {
    int n, i, j, key;
    int *a;
    scanf("%d", &n);
    a = (int *)malloc(sizeof(int) * n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);

    shell_sort(a, n);
    
    free(a);

    return 0;
}

Measured memory_bytes: 4252
#include <bits/stdc++.h>
#define _boost ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define fi first
#define se second
#define clz __builtin_clz
#define clzll __builtin_clzll
#define bp __builtin_popcount
#define _unique(x) sort((x).begin(),(x).end()),(x).erase(unique((x).begin(), (x).end()),(x.end()))
#define all(x) (x).begin(),(x).end()
#define _rand(i,j) uniform_int_distribution<int>(i, j)(rng___)
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;
template < typename _T, typename _T2> string to_string(pair<_T,_T2> x) {return "<"+to_string(x.fi)+", "+to_string(x.se)+">";}
template < typename _T> string to_string(vector<_T> vec) {string s="[ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]=']';s[s.size()-2]=' '; return s;}
template < typename _T> string to_string(set<_T> vec) {string s="{ "; for(auto el:vec)s+=to_string(el)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T, typename _T2> string to_string(map<_T,_T2> vec) {string s="{ "; for(auto el:vec)s+="mp["+to_string(el.fi)+"]= "+to_string(el.se)+", "; s[s.size()-1]='}';s[s.size()-2]=' '; return s;}
template < typename _T > inline void _DBG(const char *s, _T x){cerr << s << " = " << to_string(x) << "\n";}
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a){while(*s != ',') cerr << *s++;cerr << " = " << to_string(x) << "\n";_DBG(s + 1, a...);}
#ifdef LOCAL
#define _print(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define _print(...) ;//cout<<2;//(__VA_ARGS__)
#endif
mt19937 rng___(chrono::steady_clock::now().time_since_epoch().count());


const LL MOD = 998244353;//1e9+7;
const LL LLINF = 1e18+7;
const int N=2e5+8;


int main()
{
    _boost;
    int n,w;
    cin>>n>>w;
    vector<PLL> items(n);
    for(int i=0;i<n;i++)cin>>items[i].fi>>items[i].se;
    vector<LL> besttake(w+1,-1);
    besttake[0]=0;
    LL maxi=0;
    for(int i=0;i<n;i++)
    {
        for(int j=w;j>=0;j--)
        {
            if(besttake[j]>=0 && items[i].fi+j<=w)
            {
                besttake[j+items[i].fi]=max(besttake[j+items[i].fi],besttake[j]+items[i].se);
                maxi=max(maxi,besttake[j+items[i].fi]);
            }
        }
    }
    cout<<maxi;
}




Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        k: usize,
        r: i32,
        s: i32,
        p: i32,
        t_: String,
    }
    let t: Vec<char> = t_.chars().collect();
    let mut ret = 0;
    for i in 0..k {
        let mut a = vec![];
        for j in 0..=n / k {
            if j * k + i < n {
                a.push(t[j * k + i]);
            }
        }

        let mut pos = 0;
        while pos < a.len() {
            let c = a[pos];
            let mut count = 0;
            while pos < a.len() && a[pos] == c {
                count += 1;
                pos += 1;
            }

            if c == 'r' {
                ret += p * ((count + 1) / 2);
            } else if c == 's' {
                ret += r * ((count + 1) / 2);
            } else if c == 'p' {
                ret += s * ((count + 1) / 2);
            }
        }
    }
    println!("{}", ret);
}


Measured memory_bytes: 3044