akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
main()
{
	long long m,n;
    scanf("%lld%lld",&m,&n);
    if(m%3==0 || n%3==0)
    {
        printf("0");
        return 0;
    }
    long long mn=min(m,n);
    for(int i = 1;i < m;i++)
    {
        long long cal1=n*i;
        long long cal2=(m-i);
        cal2*=n/2;

        // long long cal2=(m-i)*n/2;

        long long cal3=m*n-cal1-cal2;
        //printf("--->%lld %lld %lld\n",cal1,cal2,cal3);
        mn=min(mn,max(max(cal1,cal2),cal3)-min(min(cal1,cal2),cal3));
    }
    for(int i = 1;i < n;i++)
    {
        long long cal1=m*i;
        long long cal2=(n-i);
        cal2*=m/2;
        long long cal3=m*n-cal1-cal2;
        //printf("%lld %lld %lld\n",cal1,cal2,cal3);
        mn=min(mn,max(max(cal1,cal2),cal3)-min(min(cal1,cal2),cal3));
    }
    printf("%lld",mn);
}


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

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

  int n, k, min = 0;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p.at(i);
  sort(p.begin(), p.end());
  rep(i, k) min += p.at(i);
  cout << min << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  std::vector<int> A;
  std::transform(S.cbegin(), S.cend(), std::back_inserter(A), [](char c) {
    return c - '1';
  });
  auto comb_parity = [&](int n, int r) {
    return (n & r) == r;
  };
  auto solve = [&](const std::vector<bool> &vec) {
    bool res = false;
    for (int i: range(0, N)) {
      if (vec[i] && comb_parity(N - 1, N - 1 - i)) {
        res = !res;
      }
    }
    return res;
  };
  {
    std::vector<bool> parity(N);
    for (int i: range(0, N)) {
      parity[i] = (A[i] % 2 == 1);
    }
    if (solve(parity)) {
      std::cout << "1\n";
      return 0;
    }
  }
  {
    std::vector<bool> two(N);
    for (int i: range(0, N)) {
      if (A[i] == 1) {
        std::cout << "0\n";
        return 0;
      }
      two[i] = (A[i] == 2);
    }
    std::cout << (solve(two) ? 2 : 0) << '\n';
  }
  return 0;
}


Measured memory_bytes: 7548
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]
let Q = input[2]

var groups = [(Int, Int, Int, Int)]()
for _ in 0 ..< Q {
    let line = readLine()!.split(separator: " ").map { Int($0)! }
    groups.append((line[0], line[1], line[2], line[3]))
}

func depthFirstSearchHighScore(_ array: [Int] = []) -> Int {
    guard array.count <= N else {
        var score = 0
        for (a, b, c, d) in groups {
            if array[b - 1] -  array[a - 1] == c {
                score += d
            }
        }
        return score
    }

    var score = 0
    for i in (array.last ?? 1) ... M {
        let newArray = array + [i]
        score = max(score, depthFirstSearchHighScore(newArray))
    }
    return score
}

print(depthFirstSearchHighScore())


Measured memory_bytes: 8308
char m[8][11]={
  "*****     ",
  "     *****",
  "==========",
  " **** ****",
  "* **** ***",
  "** **** **",
  "*** **** *",
  "**** **** "
};

main(f,i,j){
  char s[9];
  for(f=0;~scanf("%s",s);){
    if(f)puts("");
    f=1;
    for(i=0;i<8;puts(""),i++){
      for(j=0;j<5-strlen(s);j++)
        putchar(m[i][0]);
      for(j=0;j<strlen(s);j++)
        putchar(m[i][s[j]-'0']);
    }
  }
  return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<sstream>


using namespace std;

int s[100005];
int n,m,res;




int main(){

    cin >> n >> m;
    
    int l, r, cnt = 0, k = m;

    while(k--){
        cin >> l >> r;
        s[l]++;
        s[r+1]--;
      }
    
    for(int i = 1; i <= n; i++){
         s[i]+=s[i-1];
         if(s[i] == m)
             res++;           
        }
    
    
    cout << res;

   
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  while(true){
    int n;
    cin >> n;
    if(n==0) break;
    int ans=0;
    for(int j=1; j<n; j++){
      int k=0;
      for(int i=j; i<n; i++){
        k+=i;
        if(n<k) break;
        else if(n==k) ans++;
      }
    }
    cout << ans << endl;
  }
}



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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int n = max(x, y);
    int ans = 1e9;
    rep(i, n+1) {
        int cost = 2 * c * i + a * max(0, x - i) + b * max(0, y - i);
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let n = get!(usize);
    let v = get!([usize]);
    let mut sorted = v.clone();
    sorted.sort();
    for i in 0..n {
        if v[i] <= sorted[n / 2 - 1] {
            println!("{}", sorted[n / 2]);
        } else {
            println!("{}", sorted[n / 2 - 1]);
        }
    }
}


Measured memory_bytes: 10928
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<27;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n,m,s,t1,t2;
		cin>>n>>m>>s>>t1>>t2;
		if(n==0) break;
		s--;t1--;t2--;
		vvi g(n,vi(n,inf));
		for(int i=0;i<n;i++) g[i][i]=0;
		for(int i=0;i<m;i++){
			int u,v,w;
			cin>>u>>v>>w;
			u--;v--;
			g[u][v]=w;
		}
		for(int k=0;k<n;k++) for(int i=0;i<n;i++) for(int j=0;j<n;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
		int res=inf;
		for(int i=0;i<n;i++){
			res=min(res,g[s][i]+g[i][t1]+g[i][t2]);
		}
		cout<<res<<endl;
	}
}


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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S;
  string tmp= "";
  int count = 0;
  int m = 0;
  string ans;
  //main
  for(int i=0; i<S.length(); i++){
    if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
      tmp += S[i];
      count += 1; 
    }else{
      if(count > m){ m = count; ans = tmp;}
      tmp = "";
      count = 0; 
    }
  }
  if(count > m){ m = count; ans = tmp;}
  
  // output
  cout << ans.length() << endl;
  
  return 0;
}

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


using namespace std;

   // vector<string> s();

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1] == '2' || s[s.size()-1]=='4'||s[s.size()-1]=='5'||s[s.size()-1]=='7'||s[s.size()-1]=='9') {
        cout<<"hon"<<endl;
    }else if(s[s.size()-1] == '0' || s[s.size()-1]=='1'||s[s.size()-1]=='6'||s[s.size()-1]=='8') {
        cout<<"pon"<<endl;
    }else if(s[s.size()-1]=='3'){
        cout<<"bon"<<endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;

#define eps 1e-9
#define all(a)   a.begin(),a.end()
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define sz size()
#define sl(inp) scanf("%lld",&inp)
#define sd(inp) scanf("%d",&inp)

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int inf = 1e9;

ll fpow(ll base,ll power){
  ll result = 1;
  while (power > 0){
    if (power%2 == 1) result=(result*base);
  	base = (base*base);
  	power /= 2;
  }
	return result;
}

ll a[10001];

int main(){
    ll n;
    cin >> n;
    ll i;
    for ( i = 0 ; i < 2 * n ; i ++ ){
    	cin >> a[i];
    }
    sort(a, a + 2 * n);
    ll ans = 0;
    for ( i = 0 ; i < 2 * n ; i += 2 ){
    	ans += a[i];
    }
    cout << ans << "\n";
    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);

        final int N = sc.nextInt();
        final int K = sc.nextInt();

        int ans = 1;
        for (int i = 0; i < N; i++) {
            ans = Math.min(ans *  2, ans + K);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <iomanip>       // fixed, setprecision
using namespace std;

int main()
{
  int N, cc;
  cin >> N;
  vector<int> x(N), c(100, 10000 * N);
  for (int i = 0; i < N; i++)
  {
    cin >> x.at(i);
  }
  sort(x.begin(), x.end());
  for (int p = x.front(); p <= x.back(); p++)
  {
    cc = 0;
    for (auto xx : x)
    {
      cc += pow(xx - p, 2);
    }
    c[p - 1] = cc;
  }
  cout << *min_element(c.begin(), c.end()) << endl;
}


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

int main(){
  int n;
  float x,y,r,x_,y_,r_,dis;

  cin >> x >> y >> r >> x_ >> y_ >> r_;
  dis = sqrt( (x-x_)* (x-x_) +  (y-y_)* (y-y_) );

  if(r+r_ < dis){
    cout << 4 <<endl;
  }else{
    if(r+r_ == dis){
      cout << 3 <<endl;
    }else if( r+ r_ > dis && abs(r-r_)<dis ){
      cout << 2 <<endl;
    }else if( dis  == abs(r - r_)){
      cout << 1 <<endl;
    }else{
      cout << 0 <<endl;
    }
  }

}


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

using namespace std;

int main() {
    
    //forItachi
	int n,m,status=0;
	cin>>n>>m;
	vector <int> v(n,-1);
	int i ;
	for(i=0;i<m;i++){
	    int x,y;
	    cin>>x>>y;
	    if(v[x-1]==-1){
	        v[x-1]= y;
	    }
	    else{
	        if(v[x-1]!=y){
	            status = 1;
	        }
	    }
	}
	if((status==1)||(n!=1&&v[0]==0)){
	    cout<<-1<<endl;
	}
	else if(m!=0){
	    for(i=0;i<n;i++){
	        if(v[i]==-1&&i!=0){
	            cout<<0;
	        }
	        else if(v[i]==-1&&i==0){
	            cout<<1;
	        }
	        else{
	            cout<<v[i];
	        }
	    }
	}
	else if(m==0){
	    if(n==1){
	        cout<<0;
	    }
	    else if(n==2){
	        cout<<10;
	    }
	    else{
	        cout<<100;
	    }
	}
	
    
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

A_temp = make_divisors(A)
B_temp = make_divisors(B)

AB_temp = list(set(A_temp) & set(B_temp))

ans = 0

for i in AB_temp:
    count = 0
    if i > 2 and i % 2 != 0:
        for j in AB_temp:
            if i % j != 0:
                count += 1
        if count == len(AB_temp)-2:
            ans += 1
    elif i <= 2:
        ans += 1
 
print(ans)

Measured memory_bytes: 5180
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
   string s;cin>>s;
   s.erase(0,5);
   s.erase(2,1);
   int a=stoi(s);
   if(a<431)cout<<"Heisei"<<endl;
   else cout<<"TBD"<<endl;
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

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

int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

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

    // dp table
    std::vector<ll> dp(N, INF);

    // init dp table
    // ok

    // init condition
    dp[0] = 0;
    dp[1] = std::abs(h[1] - h[0]);

    // loop
    for (int i = 2; i < N; i++) {
        chmin(dp[i], dp[i-1] + std::abs(h[i-1] -h[i]));
        chmin(dp[i], dp[i-2] + std::abs(h[i-2] -h[i]));
    }

    std::cout << dp[N-1] << std::endl;
    return 0;
}

Measured memory_bytes: 1408
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vi b;
    rep(i, n) {
        if(i+1 <= (n+1)/2) {
            b.push_back(a[n-2*i-1]);
        } else {
            b.push_back(a[n-2*(n-i)]);
        }
    }

    rep(i, n-1) {
        cout << b[i] << ' ';
    }
    cout << b[n-1] << '\n';
}

Measured memory_bytes: 3828
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve(){
    string s;
    cin >> s;
    sort(ALL(s));
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

#undef int
int main() {
    init();
        solve();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int bit[10] = { 119, 36, 93, 109, 46, 107, 123, 37, 127, 111, };
inline bool is_leap(int yy) {
	return yy % 400 == 0 || (yy % 4 == 0 && yy % 100 != 0);
}
inline int day(int yy, int mm) {
	if (mm == 2) return is_leap(yy) ? 29 : 28;
	if (mm == 4 || mm == 6 || mm == 9 || mm == 11) return 30;
	return 31;
}
int N, K, a, b, dame[14][7], c1[100], c2[100];
inline int count(int x, int n) {
	int ret = 0;
	for (int i = 0; i < 7; i++) {
		if (((bit[n] >> i) & 1) && !dame[x][i]) ret++;
	}
	return ret;
}
int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++) cin >> a >> b, dame[a][b] = 1;
	for (int i = 0; i <= 9999; i++) {
		for (int j = 1; j <= 12; j++) {
			int r = day(i, j);
			for (int k = 1; k <= r; k++) {
				int z[8] = { i / 1000, i / 100 % 10, i / 10 % 10, i % 10, j / 10, j % 10, k / 10, k % 10 };
				int res = 0;
				for (int l = 0; l < 8; l++) res += count(l, z[l]);
				c1[res]++;
			}
		}
	}
	for (int i = 0; i <= 23; i++) {
		for (int j = 0; j <= 59; j++) {
			for (int k = 0; k <= 59; k++) {
				int z[6] = { i / 10, i % 10, j / 10, j % 10, k / 10, k % 10 };
				int res = 0;
				for (int l = 0; l < 6; l++) res += count(l + 8, z[l]);
				c2[res]++;
			}
		}
	}
	long long ret = 0;
	for (int i = 0; i <= N; i++) ret += 1LL * c1[i] * c2[N - i];
	cout << ret << endl;
	return 0;
}

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

using namespace std;

int n,niz[100005];
int rj[100005];

int abs(int x, int y){
	return max(x,y)-min(x,y);
}

int main () {
	
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>niz[i];
	}
	rj[0]=0;
	rj[1]=abs(niz[1],niz[0]);
	for(int i=2; i<n; i++){
		rj[i]=min(abs(niz[i],niz[i-1])+rj[i-1],abs(niz[i],niz[i-2])+rj[i-2]);
	}
	cout<<rj[n-1];
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
  int n, d;
  cin >> n >> d;
  int i=0;
  vector<int> A(200);
  int g = 1;
  while(g<16000){
   g = (i+1)*(i+1);
   A[i] = g; 
   i++; 
   //cout << g << endl; 
  }
  //rep(i, 20) cout << A[i] << endl;
  //sort(A.begin(), A.end());
  //reverse(A.begin(), A.end());
  vector<vector<int>> D(n, vector<int>(d));
  int j, k, l;
  for(j=0; j<n; j++){
    for(k=0; k<d; k++){
      cin >> D[j][k];
      //cout << D[i][j] << endl;
    }
  }
  /*for(j=0; j<n; j++){
    for(k=0; k<d; k++){
      //cin >> D[j][k];
      //cout << D[j][k] << endl;
    }
  }*/
  int np = n*(n-1)/2;
  vector<int> L(np);
  int s = 0;
  int sum=0;
  for(j=0; j<n-1; j++){
   for(l=j+1; l<n; l++){
      for(k=0; k<d; k++){
      int p = D[j][k];
      int q = D[l][k];
      //cout << p << q << endl;  
      sum += (p-q)*(p-q);  
      }
     L[s] = sum;
     sum = 0;
     s++;
   }
  }
  int ch = 0;
  for(i=0; i<np; i++){
    for(j=0; j<200; j++){
      //cout << L[i] << endl;
      if(A[j]==0) break;
      else if(L[i]==A[j]){
        //cout << L[i] << A[j] << endl;
        ch++;
        break;
      }
    }
  }
  cout << ch << endl;
}

Measured memory_bytes: 256
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%s", $S);
fscanf(STDIN, "%s", $T);

$arrS = str_split($S);
$arrT = str_split($T);

for ($i = count($arrS) - count($arrT); $i >= 0; $i--) {
    if (DEBUG) echo "i:{$i}\n";
    $tmpS = $arrS;
    $tmpT = $arrT;
    $flg = true;
    for ($j = 0; $j < count($arrT); $j++) {
        if (DEBUG) echo "{$i} {$j} {$arrT[$j]} {$arrS[$i + $j]}\n";
        if ($arrT[$j] == $arrS[$i + $j] || "?" == $arrS[$i + $j]) {

        } else {
            $flg = false;
        }
    }
    if (DEBUG) var_dump($flg);
    if ($flg) {
        $newStr = substr($S, 0, $i);
        $newStr .= $T;
        $newStr .= substr($S, strlen($newStr));     
        $newStr = str_replace("?", "a", $newStr);
        echo $newStr . PHP_EOL;
        exit;
    } else {
    }
}
echo "UNRESTORABLE\n";


Measured memory_bytes: 4728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
#define ct(string) cout << string << endl

int main() {
    int sichi=0, go=0;
    int s;
    rep(i,3) {
        cin >> s;
        if (s == 5) go++;
        if (s == 7) sichi++;
    }
    if (go == 2 && sichi == 1) ct("YES");
    else ct("NO");
}

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

int main() {
	string name;
	int a, b, visitors, fee;
	while(cin >> name >> a >> b){
		 visitors = a+b;
		 fee = a*200+b*300;
		 cout << name << ' ' << visitors << ' ' << fee << endl;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <stdio.h>

int A[50];
int fibb(int );

int main ()
{
 int i,n;
 for(i=0;i<50;i++)
   {
     A[i]=-1;
   }
 scanf("%d",&n);
 printf("%d\n",fibb(n));

 
  return 0;
  
}
int fibb(int i){

  if(i==0 ||i==1) return A[i]= 1;
  else if(A[i] !=-1) return A[i];

  return A[i] =fibb(i-1)+ fibb(i-2);

}






Measured memory_bytes: 2052
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String A = sc.next();
        String[] B = A.split("");

        int count = 0;

        for(int i=0; i<(B.length/2); i++){
            if(!B[i].equals(B[B.length-i-1])){
                count++;
            }else{
                // Nothing
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
a = int(input())
import math
u = a/1.08

ax = math.ceil(u)
z = math.floor(u)

if math.floor(ax * 1.08) != a and math.floor(z * 1.08) != a:
    print(':(')
else:
    if math.floor(ax*1.08) == a:
        print(ax)
    else:
        print(z)

Measured memory_bytes: 38384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

int main(){
	string s;
	while(getline(cin,s)&&s!="."){
		bool res = true;
		stack<char> st;
		rep(i,s.size()){
			if(s[i]=='(' || s[i]=='[')st.push(s[i]);
			if(s[i]==')'){
				if(st.size()&&st.top()=='(')st.pop();
				else {res=false;break;}
			}
			if(s[i]==']'){
				if(st.size()&&st.top()=='[')st.pop();
				else {res=false;break;}
			}
		}
		
		if(st.size()==0&&res)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
}

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define nn '\n'
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n';
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    VI b(n-1); REP(i,n-1) cin >> b[i];
    VI a(n,INF);
    REP(i,n-1){
        a[i]=min(a[i],b[i]);
        a[i+1]=min(a[i+1],b[i]);
    }
    out(accumulate(a.begin(),a.end(),0LL));

    return 0;
}

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L


typedef long long ll;


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

    int N;
    string str;
    cin>>N>>str;
    int x=0;
    vector<int> vi;
    vi.pb(0);
    for(int i=0;i<str.size();++i){
        if(str[i]=='I'){
            x+=1;
            vi.pb(x);
        }
        else{
            x-=1;
            vi.pb(x);
        }
    }
    SORT(vi);
    cout<<vi[N];
    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
	int h, w, k;
	cin>>h>>w>>k;
	char s[10][1000];
	rep(i, h) rep(j, w) cin>>s[i][j];

	int mn=INT_MAX;
	rep(co, (1<<(h-1))){
		int e=1;
		vector<int> el;
		while(e<=h){
			while(e<h && ((co>>(e-1))&1)==0) e++;
			el.push_back(e);
			e++;
		}
		int n=el.size();
		int cnt=n-1;
		vector<int> cl(n), dcl(n);
		rep(j, w){
			rep(i, n) dcl[i]=0;
			int b, e=0;
			rep(d, n){
				b=e; e=el[d];
				for(int i=b; i<e; i++) if(s[i][j]=='1') dcl[d]++, cl[d]++;
			}
			bool ng=false;
			rep(i, n) if(dcl[i]>k) ng=true;
			if(ng){
				cnt=INT_MAX;
				break;
			}
			bool slash=false;
			rep(i, n) if(cl[i]>k) slash=true;
			if(slash){
				cnt++;
				rep(i, n) cl[i]=dcl[i];
			}
		}
		mn=min(mn, cnt);
	}

	cout<<mn<<endl;

	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto&& V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;
  vector<vector<bool>> canvas(h + 2, vector<bool>(w + 2));
  rep1(i, h) {
    rep1(j, w) {
      char tmp;
      cin >> tmp;
      if (tmp == '#') canvas[i][j] = true;
    }
  }
  vector<pair<int, int>> d{{0, -1}, {0, 1}, {-1, 0}, {1, 0}};
  bool flag = true;
  rep1(i, h) {
    rep1(j, w) {
      bool check = false;
      if (!canvas[i][j]) continue;
      allrep(D, d) {
        if (canvas[i + D.first][j + D.second]) {
          check = true;
          break;
        }
      }
      if (!check) flag = false;
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  int y;
  string s;
  cin >> y >> s;
  cout << y+1 << s << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  
  if ( (r*100 + g*10 + b) % 4 == 0){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

int main() {

	int n;
	ll ans = 0;
	cin >> n;
	set<ll> a;
	map<ll, int> m;
	FOR(i, n) {
		int A;
		cin >> A;
		a.insert(A);
		m[A]++;
	}
	auto itr = a.begin();
	vector<ll> cnt;
	FOR(i, a.size()) {
		if (m[*itr] > 1) {
			if(m[*itr]>3)cnt.push_back(*itr);
			cnt.push_back(*itr);
		}
		itr++;
	}
	if (cnt.size() > 1)ans = cnt[cnt.size() - 1] * cnt[cnt.size() - 2];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s'){
        s+="es";
    }
    else{
        s+="s";
    }
    cout<<s<<endl;
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    if (s == t) cout << "EQUAL";
    else if (s.length() > t.length()) cout << "GREATER";
    else if (s.length() < t.length()) cout << "LESS";
    else if (s > t) cout << "GREATER";
    else cout << "LESS";
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};
 

int main() {
  int A, B;
  cin >> A >> B;
  if (A + B >= 10) {
    cout << "error" << endl;
  } else {
    cout << A + B << endl;
  }
  return 0;
}

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

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

#define roop(i, n) for(int i = 0;i < n;i++)

int main(void){

    int a, b;
    char o;
    cin >> a >> o >> b;

    if(o == '+')cout << a+b << endl;
    else cout << a-b << endl;

    return 0;
}

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

using namespace std;

#define INF 1e9

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

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

    char c1[60][60],c2[60][60];

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>c1[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            cin>>c2[i][j];
        }
    }

    bool ans=false;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool f=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if((i+k)>=n || (j+l)>=n){
                        f=false;
                        continue;
                    }
                    if(c1[i+k][j+l]!=c2[k][l])f=false;
                }
            }
            if(f)ans=true;
        }
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

int n, x[114], y[114], z[114];
int p, q, r;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> x[i] >> y[i] >> z[i];
		if (z[i]) {
			p = x[i], q = y[i], r = z[i];
		}
	}
	rep(i, 101)rep(j, 101) {
		int ta = r + abs(p - i) + abs(q - j);
		rep(k, n) {
			if (max(ta - abs(i - x[k]) - abs(j - y[k]), 0ll) != z[k])goto ng;
		}
		cout << i << " " << j << " " << ta << endl;
		return 0;
	ng:;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MAX=2000005;
const ll MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];
void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(ll i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(ll i,ll j){
    if(i<j) return 0;
    if(i<0||j<0) return 0;
    return fac[i]*(finv[j]*finv[i-j]%MOD)%MOD;
}
ll modpow(ll a,ll n,ll MOD){
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%MOD;
        a=a*a%MOD;
        n>>=1;
    }
    return res;
}
ll k,n;
string s;
ll ans;
int main(void){
    cin>>k>>s;
    n=s.size();
    COMinit();
    for(ll i=n;i<=n+k;i++){
        ll l=modpow(25,i-n,MOD);
        l=l*COM(i-1,n-1)%MOD;
        ll r=modpow(26,n+k-i,MOD);
        ans=(ans+(l*r)%MOD)%MOD;
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;

}




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

#define mp make_pair
typedef long long ll;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
const int N = 1e5;
ll arr[N+100];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	ll sum = 0;
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
		arr[i] *= 2;
		sum += arr[i];
	}
	sum /= 2;
	for(int i=2;i<=n;i+=2){
		sum -= arr[i];
	}
	cout << sum << " ";
	for(int i=1;i<n;i++){
		sum = arr[i]-sum;
		cout << sum << " ";
	}
	cout << "\n";
}


Measured memory_bytes: 2176
li_s = list(input())
k = int(input())
z = ord('z')
ans = ''
for i in range(len(li_s)):
    if i < len(li_s) - 1 and li_s[i] == 'a':
        ans += 'a'
    elif i < len(li_s)-1 and k-(z-ord(li_s[i])+1) >= 0:
        k -= z-ord(li_s[i])+1
        ans = ans + 'a'
    elif i < len(li_s)-1:
        ans = ans + li_s[i]
    elif i == len(li_s) - 1:
        p = ord(li_s[i])  + k
        p %= 26
        p += 78
        if 97 <= p:
            ans = ans + chr(p)
        else:
            ans = ans + chr(p+26)
print(ans)

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

int n, i, p, dist, ans = INT_MAX;
cin >> n;
int x[n];
for(i=0; i<n; i++) cin >> x[i];
for(p=1; p<=100; p++){
    dist = 0;
    for(i=0; i<n; i++){
        dist += (p-x[i])*(p-x[i]);
    }
    ans = min(ans, dist);
}
cout << ans;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
//#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define INF (int)1e15
#define MOD 1000000007
//#define N 12
#define sz 1000*1000

 int main(){
 int n,s,t=1,cnt=0;
  int64_t k;
  cin >> n >> k;
  int a[n+1],b[(1<<25)+1];

  for(int i=1;i<=n;i++)cin >> a[i];


  while(k--){
    t=a[t];
    if(b[t]) {
            k%=cnt-b[t];
            // cout<<k<<" "<<cnt<<" "<<b[t]<<endl;
    }
    b[t]=cnt++;
  }
  cout << t << endl;


 }


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001


int main(){
	
	int N,S;
	cin>>N>>S;
	
	vector<int> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	
	vector<vector<int>> dp(N+1,vector<int>(S+1,0));
	dp[0][0] = 1;
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=0;j<=S;j++){
			dp[i+1][j] = mod(dp[i+1][j] + dp[i][j]);
			int x = j+A[i];
			if(x>S)continue;
			dp[i+1][x] = mod(dp[i+1][x] + dp[i][j]);
		}
		ans = mod(ans + dp[i+1][S]);
		
		dp[i+1][0] = mod(dp[i+1][0] + 1);
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 35584
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

ll f(ll b, ll n) {
  if (n < b) return n;
  else return f(b, n/b) + (n % b);
}

int main() {
  ll n, s; cin >> n >> s;
  ll b = 2;
  if (n == s) {cout << n+1 << endl; return 0;}
  while (b*b <= n) {
    if (f(b, n) == s) {cout << b << endl; return 0;}
    b++;
  }
  ll p = 1LL;
  ll minb = HIGHINF;
  while (p*p < n) {
    b = (n-s+p) / p;
    if (b < 2) {p++; continue;}
    if (f(b, n) == s) chmin(minb, b);
    p++;
  }
  if (minb == HIGHINF) cout << -1 << endl;
  else cout << minb << endl;
  return 0;
}


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

int main() {
    int n, a;
    cin >> n >> a;
    if(n%a == 0){
        cout << n/a << endl;
    }else{
        cout << n/a+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
cards = [[0 for i in range(13)] for j in range(4)]
s2n = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
n2s = 'SHCD'
n = int(input())
for i in range(n):
    card = list(input().split())
    card[1] = int(card[1])
    cards[s2n[card[0]]][card[1]-1] = 1
for i in range(4): 
    for j in range(13):
        if not(cards[i][j]):
            print(n2s[i], j+1)

Measured memory_bytes: 7648
<?php
 
function input_and_explode() {
    $input_line = trim(fgets(STDIN));
    return explode(" ", $input_line);
}

$N = (int)input_and_explode()[0];

$S = [];

while (abs($N) > 0) {
    // $S[] = $N - (-2) * intdiv($N, -2);
    // $N = intdiv($N, -2);
    if ($N < 0) {
        if (abs($N) % 2 === 0) {
            $S[] = $N - (-2) * intdiv(abs($N), 2);
            $N = intdiv(abs($N), 2);
        } else {
            $S[] = $N - (-2) * (intdiv(abs($N), 2) + 1);
            $N = intdiv(abs($N), 2) + 1;
        }
    } else {
        $S[] = $N - (-2) * (- intdiv(abs($N), 2));
        $N = - intdiv(abs($N), 2);
    }
}

$S = array_reverse($S);

if ($S === []) {
    $S = '0';
} else {
    $S = implode('', $S);
}

echo "$S\n";

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

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n+1);
    for ( int i=0; i<n; i++ ) {
        cin >> a[i];
    }
    for ( int i=0; i<k; i++ ) {
        vector<int> b(n+1);
        for ( int i=0; i<n; i++ ) {
            int l=max(0,i-a[i]);
            int r=min(n,i+a[i]+1);
            b[l]++; b[r]--;
        }
        a[0]=b[0];
        for ( int i=1; i<n; i++ ) {
            b[i]+=b[i-1];
            a[i]=b[i];
        }
        bool flag=1;
        for ( int i=0; i<n; i++ ) {
            if ( a[i]!=n ) {
                flag=0;
                break;
            }
        }
        if ( flag ) break;
    }
    for ( int i=0; i<n; i++ ) {
        cout << a[i] << ' ';
    }
    return 0;
}

Measured memory_bytes: 4772
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a){
        cout<<k<<endl;
        return 0;
    }
    else if(k <= a+b){
        cout<<a<<endl;
        return 0;
    }
    else {
        cout<<a-(k-a-b)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;


int main() {

	int n;
	cin >> n;
	vector<int> p(n);
	vector<int> q(n);
	rep(i, n) cin >> p.at(i);
	rep(i, n) cin >> q.at(i);
	vector<int> a(n);
	rep(i, n) a.at(i) = i + 1;

	int cnt = 0;
	int pcnt = 0;
	int qcnt = 0;
	do{
		cnt++;
		if (a == p)  pcnt = cnt;
		if (a == q)  qcnt = cnt;

	} while (next_permutation(a.begin(), a.end()));
	
	cout << abs(pcnt - qcnt) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	
	vector<int> p(m),y(m);
	vector<vector<int> > id(n);
	REP(i,m){
		cin>>p[i]>>y[i];
		id[p[i]-1].push_back(y[i]);
	}
	
	REP(i,n){
		sort(ALL(id[i]));
	}
	
	REP(i,m){
		int tmp=lower_bound(ALL(id[p[i]-1]),y[i])-id[p[i]-1].begin()+1;
		printf("%06d%06d\n",p[i],tmp);
	}
}//解答解説参考.

Measured memory_bytes: 7808
#include <stdio.h>

int main()
{
	int i;
	char buf[20], str[20];
	
	scanf("%s", str);
	
	for (i = (sprintf(buf, "%s", str) - 1); i >= 0; i--)
		printf("%c", str[i]);
	
	putchar('\n');
		
	return 0;
}

Measured memory_bytes: 544
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int ans1 = 0, ans = 0;
		List<Integer> a = new ArrayList<>();
		int con = 1;
		if(N == 1)
			a.add(1);
		for(int i = 1; i < N; i++) {
			if(S[i] == S[i-1]) {
				con += 1;
			}
			else {
				a.add(con);
				con = 1;
			}
			if(i == N-1)
				a.add(con);
		}
		if(S[0] == '1') {
			LOOP:for(int i = 0; i < a.size(); i += 2) {
				ans1 = 0;
				for(int j = i; j <= i + K*2 && j < a.size(); j++) {
					ans1 += a.get(j);
				}
				ans = Math.max(ans, ans1);
				if(i + K*2 >= a.size())
					break LOOP;
			}
		}
		else {
			for(int i = 0; i < K*2 && i < a.size(); i++)
				ans += a.get(i);
			LOOP:for(int i = 1; i < a.size(); i += 2) {
				ans1 = 0;
				for(int j = i; j <= i + K*2 && j < a.size(); j++) {
					ans1 += a.get(j);
				}
				ans = Math.max(ans, ans1);
				if(i + K*2 >= a.size())
					break LOOP;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 28656
A,B,M = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
XYC = [[int(i) for i in input().split()] for j in range(M)]

res = 10**9
for x,y,c in XYC:
    res = min(res,a[x-1]+b[y-1]-c)
res = min(res,min(a)+min(b))
print(res)

Measured memory_bytes: 32496