akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline


def divide(n):
    c1, c2 = 0, 0
    while (n%2 == 0):
        c1 += 1
        n //= 2
    while (n%5 == 0):
        c2 += 1
        n //= 5
    return (c1, c2)
    

def main():
    n = int(input())
    a = [None]*n
    for i in range(n):
        sub = input().replace("\n", "")
        if "." in sub:
            x, y = map(str, sub.split("."))
            s = int(x)*1000000000+10**(9-len(y))*int(y)
        else:
            s = int(sub)
            s *= 1000000000
        a[i] = divide(s)

    dp = [[0]*100 for _ in range(100)]
    for i in range(n):
        c1, c2 = a[i]
        dp[c1][c2] += 1
    
    for i in range(98, -1, -1):
        for j in range(98, -1, -1):
            dp[i][j] += dp[i+1][j]+dp[i][j+1]-dp[i+1][j+1]

    ans = 0
    for i in range(n):
        c1, c2 = a[i]
        if (c1 >= 9 and c2 >= 9):
            ans -= 1
        if c1 >= 18 and c2 >= 18:
            ans += dp[0][0]
            continue
        if c1 >= 18:
            ans += dp[0][18-c2]
            continue
        if c2 >= 18:
            ans += dp[18-c1][0]
            continue
        ans += dp[18-c1][18-c2]
        
    print(ans//2)
    
    
    
if __name__ == "__main__":
    main()


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

using namespace std;

const int Nmax = 2e5 + 5;
const int Mod = 1e9 + 7;
const int oo = 2e9;

int n;
map <string, int> m;

int main()
{
/**
    #ifndef ONLINE_JUDGE

        ifstream cin("test.in");

    #endif // ONLINE_JUDGE
*/

    cin >> n;

    string s;

    while(n--)
    {
        cin >> s;
        m[s] = 1;
    }

    cout << m.size();
    return 0;
}


Measured memory_bytes: 19176
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int n = in.nextInt();
        int w = in.nextInt();
        int []weights = new int[n];
        int []values =  new int[n];
        for(int i=0;i<n;i++){
            weights[i] = in.nextInt();
            values[i] = in.nextInt();
        }
        long [][]dp = new long[n+1][w+1];
        for(int i=1;i<=n;++i){
            for(int k = 1;k<=w;++k ) {
                if(weights[i-1]<=k){
                    dp[i][k] = Math.max(dp[i-1][k],values[i-1]+dp[i-1][k-weights[i-1]]);
                }else{
                    dp[i][k] = Math.max(dp[i][k-1],dp[i-1][k]);
                }
            }
        }
        System.out.println(dp[n][w]);
    }
}


Measured memory_bytes: 124372
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;

    cin >> k;

    cout << a[k-1];
}

Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
ss = sum(w)
s = [w[0]]
for i in range(n-2):
    s.append(s[-1]+w[i+1])
ans = float("inf")
for i in s:
    ans = min(ans, abs(abs(ss-i)-i))
print(ans)

Measured memory_bytes: 38448
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int ab(int x){
    return x<0?-x:x;
}
int power(int a,int b){
    int ans=1;
    a%=mod;
    while(b){
        if(b&1){
            ans=ans*a%mod;
            b--;
        }
        b>>=1;
        a=a*a%mod;
    }
    return ans%mod;
}
int fermat(int a){
    return power(a,mod-2);
}
bool cmp(int a,int b){
    return ab(a)<ab(b);
}
main(){
//    freopen("in.txt","r",stdin);
    int n,k;
    cin>>n>>k;
    vector<int>a;
    int flag=0;
    for(int i=0;i<n;++i){
        int x;
        cin>>x;
        if(x>0)flag++;
        a.push_back(x);
    }
    sort(a.begin(),a.end(),cmp);
    if((!flag&&(k&1))||(k==n&&((n-flag)&1))){
        int ans=1;
        for(int i=0;i<k;++i){
            ans=ans*a[i]%mod;
        }
        cout<<(ans+mod)%mod<<endl;
        return 0;
    }
    int ans=1;
    for(int i=n-1;i>=n-k;i--){
        ans=ans*a[i]%mod;
    }
    if(ans<0){
        int mx=-inf;
        int mi=inf;
        for(int i=n-1;i>=n-k;--i){
            if(a[i]<0)mx=max(mx,a[i]);
            else mi=min(mi,a[i]);
        }
        int mxp=-1;
        int mip=0;
        for(int i=0;i<n-k;++i){
            if(a[i]>=0)mxp=max(mxp,a[i]);
            else mip=min(mip,a[i]);
        }
        if(mi==inf||mip==0){
            ans=ans*mxp%mod;
            ans=ans*fermat(mx)%mod;
        }else if(mx==-inf||mxp==-1){
            ans=ans*mip%mod;
            ans=ans*fermat(mi)%mod;
        }else if(mip*mx>mi*mxp){
            ans=ans*mip%mod;
            ans=ans*fermat(mi)%mod;
        }else{
            ans=ans*mxp%mod;
            ans=ans*fermat(mx)%mod;
        }
        cout<<ans%mod<<endl;
    }else cout<<ans%mod<<endl;
}


Measured memory_bytes: 5376
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>

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

using namespace std;
int N,K;
int h[200000];
int sa[200000];
int main(){
	cin >> N >> K;
  REP(i,N) cin >> h[i];
  sort(h,h+N);
  REP(i,N-K+1){
    sa[i]=h[i+K-1]-h[i];
  }
  sort(sa,sa+N-K+1);
  cout << sa[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
 
 
typedef long long ll;
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'


int main() {
  int h, w, a, b;
  cin >> h >> w >> a >> b;

  vector<string> s(h, string(w, '?'));
  rep (i, b) {
    rep (j, a) {
      s[i][j] = '0';
    }
    for (int j = a; j < w; j++) {
      s[i][j] = '1';
    }
  }

  for (int i = b; i < h; i++) {
    rep (j, a) s[i][j] = '1';
    for (int j = a; j < w; j++) {
      s[i][j] = '0';
    }
  }

  rep (i, h) {
    cout << s[i] << endl;
  }
}


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

int main() {
  long long int N, M;
  cin >> N >> M;
  if(N==1&&M==1) cout << 1 << endl;
  else if(N==1 || M==1) cout << N*M-2 << endl;
  else cout << (N-2) * (M-2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N,i,max,min;
	max = 0;
	min = 1000000000;
	scanf("%d",&N);
	int A[N];
	for(i=0;i<N;i++){
		scanf("%d",&A[i]);
		if( A[i] > max){
			max = A[i];
		}
		if( A[i] < min){
			min = A[i];
		}
	}
	printf("%d", max - min);
	return 0;
}

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

int main(){
	int N;
	long long ans = 0;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++){
		cin >> A[i];
		A[i] -= (i+1);
	}

	sort(A.begin(), A.end());
	int median = A[N/2];
	
	for(int i = 0; i < N; i++){
		ans += abs(A[i] - median);
	}
	cout << ans << endl;
}



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

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// Type / Class / Struct Definitions:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;

// Global Variables:

// Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    int x, ans = 0;
    a[0] = 0;
    b[0] = 0;
    rep(i, n) {
        cin >> x;
        a[i + 1] = a[i] + x;
        if(a[i + 1] <= k) ans = i + 1;
    }
    rep(i, m) {
        cin >> x;
        b[i + 1] = b[i] + x;
    }

    int kari = 0;
    for(int i = ans; i >= 0; i--) {
        while(kari <= m && a[i] + b[kari] <= k) {
            kari++;
        }
        if(kari > 0) kari--;
        chmax(ans, i + kari);
    }
    cout << ans << endl;
    return 0;
}
// ===========================================

// Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


Measured memory_bytes: 6420
#include<stdio.h>
int main(void){
    char str[1200];
    int i;
    fgets(str,sizeof(str),stdin);
    for(i=0;str[i]!='\0';i++){
        if(str[i]>='A' && str[i]<='Z'){
            str[i]+=('a'-'A');
        }
        else if(str[i]>='a' && str[i]<='z'){
            str[i]-=('a'-'A');
        }
    }
    printf("%s",str);
    return 0;
}


Measured memory_bytes: 2032
#include<stdio.h>
int p[10000],d[10000];
int main(void)
{
	int n,i,j,d1,d2,T,max=0,maxn;
	while(1){
		max = 0;
	scanf("%d",&n);
	if(n == 0)
		break;
	for(i=0;i<n;i++){
		scanf("%d %d %d",&p[i],&d1,&d2);
		d[i] = d1+d2;
	}
	for(i=0;i<n;i++){
		if(max < d[i]){
			max = d[i];
			maxn = p[i];
		}
	}
	printf("%d %d\n",maxn,max);
	}
	return 0;
}

Measured memory_bytes: 676
// https://atcoder.jp/contests/abc146/tasks/abc146_d

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;

int N;
// int a[N_MAX];
// int b[N_MAX];

int K;
int c[N_MAX];

//------------------------------------------------------------------------------
const int V_MAX = N_MAX;

struct edge { int to, i; };

vector<edge> G[V_MAX];

void add_edge(int from, int to, int i) {
  G[from].push_back({ to, i });
  G[to].push_back({ from, i });
}

void dfs(int p, int pc, int v) {
  int uc = 1;
  REP(i, G[v].size()) {
    edge e = G[v][i];
    int u = e.to;
    if (u == p) continue;
    if (uc == pc) uc++;
    c[e.i] = uc;
    K = max(K, uc);
    dfs(v, uc, u);
    uc++;
  }
}

void solve() {
  dfs(-1, -1, 0);
  printf("%d\n", K);
  REP(i, N - 1) printf("%d\n", c[i]);
}

void input() {
  scanf("%d", &N);
  REP(i, N - 1) {
    int a, b;
    scanf("%d%d", &a, &b);
    add_edge(a - 1, b - 1, i);
  }
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 9344
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;

vector<vector<int>> dp;
vector<set<int>> edge;

bool match(int p, int q){
    return edge[p].count(q) > 0;
}


int search(const int l, const int r){
    if(l >= r) return 0;
    if(dp[l][r] > -1) return dp[l][r];
    int cand = search(l+1, r);
    for (auto &&u : edge[l]) {
        if(u > r) continue;
        int sc = search(l+1, u-1);
        if(sc == u - l - 1){
            cand = max(cand, sc + 2 + search(u+1, r));
        }
    } // end u
//    for (int i = l+1; i < r-1; ++i) {
//        cand = max(cand, search(l, i) + search(i+1, r));
//    } // end i

    return dp[l][r] = cand;
}


int main(){
    while(cin) {
        int n;
        cin >> n;
        if(n == 0) return 0;
        vector<int> w(n);
        for (auto &&i : w) {
            cin >> i;
        } // end i
        edge.clear();
        dp.clear();
        edge.resize(n);
        dp.resize(n, vector<int>(n, -1));

        for (int i = 0; i < n; ++i) {
            int p = w[i];
            for (int j =i+1; j < n; j+=2) {
                int q = w[j];
                if(abs(p - q) <= 1){
                    edge[i].insert(j);
                }
            } // end j
        } // end i
        cout << search(0, n-1) << endl;

    }
}


Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 int a[3];
 for(ll i=0;i<3;i++)cin>>a[i];
 int sum = 0;
 int k;
 cin>>k;
 for(ll i=0;i<2;i++){
  while( a[i] >= a[i+1] ){
   a[i+1]*=2;
   sum++;
  }
 }
 if( sum <= k ){
  cout<<"Yes"<<endl;
 }else{
  cout<<"No"<<endl;
 }
    return 0;
}


Measured memory_bytes: 3588
import * as fs from 'fs'
import {debug} from '../../../util'

const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split(' ').map(n => parseInt(n, 10))
const output = (x: any) => console.log(x)
// debug(input)
let [A, B, C, K] = input
let iterate = 0
let sum = 0
while (K) {
    const m = Math.min(input[iterate], K)
    if (iterate === 0) {
        sum += m
    } else if (iterate === 1) {}
    else {
        sum -= m
    }
    input[iterate] -= m
    K -= m
    if (K === 0) break
    if (input[iterate] === 0) ++iterate
}
output(sum)

Measured memory_bytes: 29804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    vector<ll> a(N+1);
    for(int i=1; i<=N; i++) cin >> a[i];

    vector<ll> cum(N+1, 0);
    vector<ll> cum2(N+1, 0);
    for(int i=1; i<=N; i++) cum[i] = cum[i-1]+a[i];
    for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0LL, a[i]);

    ll ans = -(1LL<<59);
    for(int i=1; i<=N+1-K; i++){
        ll tmp = cum[i+K-1]-cum[i-1];
        ll tmp2 = 0;
        tmp += cum2[i-1] + cum2[N]-cum2[i+K-1];
        tmp2 += cum2[i-1] + cum2[N]-cum2[i+K-1];

        ans = max(ans, max(tmp, tmp2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>


int main() {
  int a, b, c;
  int count = 0; 
  std::cin >> a >> b >>  c;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) count ++;
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
  ll n,ans,an,a5,a6,a7;
  an=1000000007;
  cin>>n;
  a7=1;
  a5=1;
  a6=1;
  rep(i,n){
    a7=(a7*9)%an;
    a5=(a5*10)%an;
    a6=(a6*8)%an;
  }
  ans=(((a5-a7)*2)%an-(a5-a6)%an)%an;
  ans=(ans+an)%an;
  cout<<ans%an<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if ((abs(a-b) <= d && abs(c-b) <= d) || abs(a-c) <= d) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main()
{
    int x, y;
    cin >> x >> y;

    rep(i,x+1){
      if(i*2 + (x-i)*4 == y){
        cout << "Yes" << endl;
        return 0;
      } 
    }

    cout << "No" << endl;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }

    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update)
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};
int main(){
    string s;
    ll n,q;cin >> n  >> s>>q;
    SegTree<ll> st(n,0LL,[](ll a,ll b){return (a|b);},[](ll a,ll b){return b;});
    rep(i,n){
        ll bit=1LL<<(s[i]-'a');
        st.change(i,bit);
    }
    rep(i,q){
        ll type;cin >> type;
        if(type==1){
            ll x;char ch;
            cin >> x >>ch;x--;
            ll bit=1LL<<(ch-'a');
            st.change(x,bit);
        }
        else{
            ll l,r;cin >> l >>r;l--;
            ll ans=st.query(l,r);
            cout <<__builtin_popcount(ans) <<endl;
        }
    }
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n - 1] == 's') {
        cout << s << "es" << endl;
    }else{
        cout << s << "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<string>
#include<string.h>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<climits>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long int r,d,x2000;
    cin>>r>>d>>x2000;
    vector<long long int>values;
    values.push_back(x2000);
    for(int i=0;i<10;i++){
        values.push_back(r*values[values.size()-1]-d);
    }
    sort(values.begin(),values.end());
    for(int i=1;i<values.size();i++){
        cout<<values[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int n;
cin>>n;
string s;
s=to_string(n);
int ct=0;
for(int i=0;i<s.length()/2;i++)
{
	if(s[i]==s[s.length()-1-i])
	ct++;
	
}
if(ct==s.length()/2)
cout<<"Yes"<<"\n";
else
cout<<"No"<<"\n";
}

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

// 線形探索
// 番兵法を用いています
bool search(int A[], int n, int key) {
    int i = 0;

    // 探索対象の配列の最後に探索keyを入れる
    A[n] = key;
    // keyと一致するものが無くても最後には絶対ループを抜ける
    while (A[i] != key) {
        ++i;
    }

    // true/falseを返している(i != n なら　falseを返却)
    return i != n;
}

int main() {
    int n, S[10100], q, T[600];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> S[i];
    }

    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> T[i];
    }

    int sum = 0;
    for (int i = 0; i < q; ++i) {
        int key = T[i];
        if (search(S, n, key)) {
            ++sum;
        }
    }

    cout << sum << endl;

    return 0;
}


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

int const N = 200000;
vector<int> g[N + 1];
char cl[N + 2], z[] = "AABB";
int vis[N + 1][4];

bool go(int v, int j){
	vis[v][j] = 1;
	int nj = j + 1;
	if (nj == 4)nj = 0;
	f(i, 0, g[v].size()){
		int u = g[v][i];
		if (cl[u] != z[nj])continue;
		if (vis[u][nj] == 1)return true;
		if (!vis[u][nj] && go(u, nj))return true;
	}
	vis[v][j] = 2;
	return false;
}

int main(){
	int n, m;
	scanf("%d%d%s", &n, &m, cl + 1);
	f(i, 0, m){
		int a, b;
		scanf("%d%d", &a, &b);
		g[a].push_back(b), g[b].push_back(a);
	}
	f(i, 1, n + 1)if (cl[i] == 'B' && !vis[i][2] && !vis[i][3] && go(i, 3)) { printf("Yes\n"); return 0; }
	printf("No\n");
}

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

enum { U, B, L, F, R, D };
struct Dice {
	int face[6];

	Dice() {
		face[F] = 1;
		face[R] = 2;
		face[U] = 3;
		face[B] = 6;
		face[L] = 5;
		face[D] = 4;
	}

	int find_face(int f) {
		for(int i = 0; i < 6; i++) {
			if(face[i] == f) return i;
		}
		return -1;
	}

	void turn(int dir) {
		switch(dir) {
		case R:
			rotate(U, R, D, L);
			break;
		case B:
			rotate(U, B, D, F);
			break;
		case L:
			rotate(U, L, D, R);
			break;
		case F:
			rotate(U, F, D, B);
			break;
		case U:
			rotate(F, R, B, L);
			break;  // ??????????????????????¨???????
		case D:
			rotate(F, L, B, R);
			break;  // ??????????????????????¨???????
		default:
			assert(false);
		}
	}

	int& operator[](int n) { return face[n]; }

	const int& operator[](int n) const { return face[n]; }

	std::vector<Dice> all_rolls() {
		std::vector<Dice> res;
		for(int k = 0; k < 6; k++) {
			for(int i = 0; i < 4; i++) {
				res.push_back(*this);
				turn(R);
			}
			turn(k % 2 == 1 ? U : F);
		}
		return res;
	}

	void rotate(int a, int b, int c, int d) {
		int t = face[d];
		face[d] = face[c];
		face[c] = face[b];
		face[b] = face[a];
		face[a] = t;
	}
};

typedef pair<int, int> P;

Dice dice[15];
int X[15], Y[15];
string rot[15];
map<P, int> pos[15];
int dp[1 << 15];
set<P> used[1 << 15];

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

	int N;
	while(cin >> N, N) {
		for(int i = 0; i < N; i++) {
			int l, r, f, b, d, u;
			cin >> X[i] >> Y[i];
			cin >> l >> r >> f >> b >> d >> u;
			cin >> rot[i];
			dice[i][L] = l;
			dice[i][R] = r;
			dice[i][F] = f;
			dice[i][B] = b;
			dice[i][D] = d;
			dice[i][U] = u;

			Dice t = dice[i];
			int x = X[i], y = Y[i];
			pos[i].clear();
			pos[i][{ x, y }] = t[D];
			for(auto c : rot[i]) {
				if(c == 'L') t.turn(L), x--;
				if(c == 'R') t.turn(R), x++;
				if(c == 'F') t.turn(F), y--;
				if(c == 'B') t.turn(B), y++;
				pos[i][{ x, y }] = t[D];
			}
		}

		for(int i = 0; i < 1 << N; i++) {
			used[i].clear();
			for(int j = 0; j < N; j++) {
				if(i >> j & 1) {
					for(auto p : pos[j]) {
						int x = p.first.first, y = p.first.second;
						used[i].insert({ x, y });
					}
				}
			}
		}

		memset(dp, 0, sizeof dp);
		dp[0] = 0;
		for(int i = 0; i < 1 << N; i++) {
			if(dp[i] == -1) continue;
			int s = dp[i];
			for(int j = 0; j < N; j++) {
				if(i >> j & 1) continue;
				int ns = s;
				for(auto p : pos[j]) {
					int x = p.first.first, y = p.first.second;
					int point = p.second;
					if(used[i].count({ x, y })) continue;
					ns += point;
				}
				dp[i | (1 << j)] = max(dp[i | (1 << j)], ns);
			}
		}

		cout << dp[(1 << N) - 1] << endl;
	}
}

Measured memory_bytes: 235240
#include <algorithm>
#include <cstdio>

const int N = 100000;

int n, a[N], ord[N];

bool by_a(int i, int j)
{
    return a[i] < a[j];
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
        ord[i] = i;
    }
    std::sort(ord, ord + n, by_a);
    int result = 0;
    for (int i = 0; i < n; i += 2) {
        result += (ord[i] & 1);
    }
    printf("%d\n", result);
}


Measured memory_bytes: 896
#include <iostream>
using namespace std;
 
int main() {
    //Recieve the inputs
    int D, T, S;
    cin >> D >> T >> S;
 
    //Calculate the possible distance of Takahashi's travel
    int dist = S * T;
 
    //Output depending on the inequality between D and dist
    if (dist >= D) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
import numpy as np

N = int(input())
d = list(map(int, input().split()))

arr_d = np.array(d)

d_sorted = np.sort(arr_d)

n1 = int(N / 2)
n2 = int(N / 2 - 1)

ans = d_sorted[n1] - d_sorted[n2]

print(ans)


Measured memory_bytes: 23388
#include <stdio.h>
#pragma warning( disable:4996 )
int main() {
	int a[3] = { 0 }, b[3] = { 0 }, count[4] = { 0 };
	for (int i = 0; i < 3; i++) {
		scanf("%d %d", &a[i], &b[i]);
		count[a[i]-1]++;
		count[b[i]-1]++;
	}
	for (int i = 0; i < 4; i++) {
		if ((count[i] != 1 && count[i] != 2)) {
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int R = scanner.nextInt();

        if(N<10){
            System.out.println(R+(100*(10-N)));
        }else{
            System.out.println(R);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<vector<ll>> g;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, m;
    cin >> n >> m;
    
    g = vector<vector<ll>>(n, vector<ll>());
    
    for (int i = 0; i < m; ++i)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    
    vector<ll> ret(n);
    vector<bool> used(n);
    queue<P> q;
    q.push(P(-1, 0));
    
    while (q.size() > 0)
    {
        P cur = q.front();
        q.pop();
        if (used[cur.second])
        {
            continue;
        }
        used[cur.second] = 1;
        ret[cur.second] = cur.first + 1;
        for (int i = 0; i < g[cur.second].size(); ++i)
        {
            q.push(P(cur.second, g[cur.second][i]));
        }
    }
    
    cout << "Yes" << endl;
    
    for (int i = 1; i < n; ++i)
    {
        cout << ret[i] << endl;
    }

    return 0;
}

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

int main() {
    string s;
    string t = "yuiophjklnm";
    while (cin >> s, s != "#") {
        int count = 0;
        bool p = (t.find(s[0]) == string::npos);
        for (int i = 1; i < s.size(); i++) {
            if ((t.find(s[i]) == string::npos) != p) {
                count++;
                p = (t.find(s[i]) == string::npos);
            }
        }
        cout << count << endl;
    }
    
    return 0;
}



Measured memory_bytes: 3084
#include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <queue>
#include <random>

using namespace std;

#define INT_MAX_VALUE 2147483647
#define LONG_LONG_MAX_VALUE 9223372036854775807
#define ll long long
#define ld long double

struct XX{
    ll la;
    ll lb;
    ll ra;
    ll rb;
    ll q;
};

class xxGreater {
public:
    bool operator()(const XX& riLeft, const XX& riRight) const {
        //第2条件
        if((riLeft.q) == (riRight.q)){
            return riLeft.q < riRight.q;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
            //プライオリティキューの場合は > で、top()すると値の小さいものがとれる
        }
        //第1条件
        return (riLeft.q) < (riRight.q);
    }
};


//map<long long,long long> prime_f(long long n){
//    map<long long,long long>res;
//    for(int i=2;i*i<=n;i++){
//        while(n%i==0){
//            ++res[i];
//            n/=i;
//        }
//    }
//    if(n!=1)res[n]=1;
//    return res;
//}


int n;
//int dat[2*10000000];
//int dat2[2*10000000];
int dat[2*100];
int dat2[2*100];

void init(int n_){
    n=1;
    while(n<n_)n*=2;
    for(int i=0;i<2*n-1;i++){
        dat[i]=0;
        dat2[i]=0;
    }
}

void initset(int k,int a){
    k+=n-1;
    dat[k]=a;
    while(k>0){
        k=(k-1)/2;
        dat[k]=dat[k*2+1]+dat[k*2+2];
    }
}

//[a,b)の間を[l,r]区間で比較しアップデート
//引数のindexに注意
//nは固定。initで計算すみ
//update2(L[i],R[i]+1,0,0,n,D[i]);
void update2(int a,int b,int k,int l,int r,int v){//v更新値、区間は0-index
    if(r<=a || b<=l)return;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=v*(r-l);
        return;
    }else{
        update2(a,b,k*2+1,l,(l+r)/2,v);
        update2(a,b,k*2+2,(l+r)/2,r,v);
        return;
    }
}

int query(int a,int b,int k,int l,int r){
    if(r<=a || b<=l)return 0;
    if(a<=l && r<=b){
        dat[k]+=dat2[k];
        if(r-l>1){
            dat2[k*2+1]+=dat2[k]/2;
            dat2[k*2+1]+=dat2[k]/2;
        }
        dat2[k]=0;
        return dat[k];
    }
    else{
        int vl=query(a,b,k*2+1,l,(l+r)/2);
        int vr=query(a,b,k*2+2,(l+r)/2,r);
        return vl+vr;
    }
}


int main(int argc, const char * argv[])
{
    //scanf("%s",S);
    //scanf("%d",&N);
    //scanf("%lld %lld",&target1,&target2);
    //sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
    //getline(cin, target);
    //ifstream ifs( "1_06.txt" );//テスト用
    //ifs >> a;
    //ここから
    
    //入力高速化
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    cin >> a >> b;
    int sa=b-a;
    int takasa=0;
    while(sa>0){
        takasa+=sa;
        sa--;
    }
    cout << takasa-b << endl;

    //ここまで
    //cout << "ans" << endl;改行含む
    //printf("%.0f\n",ans);//小数点以下表示なし
    //printf("%.7f\n",p);
    
    return 0;
}




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

const int N = 3005;
const double PI = acos(-1);
int n, L, T[N];

int main() {
	scanf("%d%d", &n, &L);
	for (int i = 1; i <= n; ++i)
		scanf("%d", T + i);
	double sx = 0, sy = 0;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) {
			double arg = (T[i] + T[j]) * PI / L;
			sx += cos(arg) * (n - j + i - 1), sy += sin(arg) * (n - j + i - 1);
			arg = T[j] * 2 * PI / L + (T[i] + L - T[j]) * PI / L;
			sx += cos(arg) * (j - i - 1), sy += sin(arg) * (j - i - 1);
		}
	sx /= 1ll * n * (n - 1) * (n - 2) / 6;
	sy /= 1ll * n * (n - 1) * (n - 2) / 6;
	printf("%.15lf %.15lf\n", sx, sy);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n;
    cin>>n;
    ll a[n];
    ll cnt[n+1]={0};
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cnt[a[i]]++;
    ll dp[n+1]={0},sum=0;
    for(ll i=1;i<=n;i++)
    {
        dp[i]=cnt[i]*(cnt[i]-1)/2;
        sum+=dp[i];
    }
    for(ll i=0;i<n;i++)
    {
        ll x=cnt[a[i]]-1;
        ll ans=sum-dp[a[i]]+x*(x-1)/2;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 7296
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean seven = false;
        if(n/100 == 7){
            seven = true;
        }
        if(((n/10) % 10) == 7){
            seven = true;
        }
        if((n % 10) == 7){
            seven = true;
        }
        System.out.println(seven ? "Yes" : "No");
    }
}


Measured memory_bytes: 35732
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left";else
	if(a+b==c+d)cout<<"Balanced";else
	cout<<"Right";
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    ll N,A,B;
    cin >> N >> A >> B;
    if((B-A)%2==0){
        cout << (B-A)/2 << endl;
    }else{
        ll tmp=min(A-1, N-B);
        cout << tmp+(B-A+1)/2 << endl;
    }




    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    vector<int> d(n+10);
    d[0] = 0;
    int ans = 1;
    for (int i = 0; i < n; i++) {
       d[i+1] = d[i]+ l[i];
       if (d[i+1] <= x) {
           ans++;
       }
       else break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
    string A,B;
    cin >> A >> B;
    if(A.size() > B.size()) {
        cout << "GREATER" << endl;
        return 0;
    }
    else if(A.size() < B.size()){
        cout << "LESS" << endl;
        return 0;
    }
    else{
        rep(i,A.size()){
            int a  =(char)(A[i]-'0');
            int b = (char)(B[i]-'0');
            if(a > b) {
                cout << "GREATER" << endl;
                return 0;
            }
            else if(a < b) {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long findNumberOfTriangles(long long arr[], long long n)
{
   long long count = 0;
    for (long long i= 0; i < n; i++)
    {
        for (long long j = i + 1; j < n; j++)
        {
            for (long long k = j + 1; k < n; k++){
                    if(arr[i]==arr[j]||arr[k]==arr[j]||arr[i]==arr[k])
                    continue;
                    if (
                    arr[i] + arr[j] > arr[k]
                    && arr[i] + arr[k] > arr[j]
                    && arr[k] + arr[j] > arr[i])
                    count++;
            }


        }
    }
    return count;
}

int main()
{
    long long n,arr[104],i;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>arr[i];

    cout<< findNumberOfTriangles(arr, n);

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;

  string t = "";
  
  for(int i = 0 ; i < (int)s.size() ; i++){
    if(s[i] == 'A' || s[i] == 'Z') t += s[i];
  }

  string ans;
  bool f = true;
  
  for(int i = 0 ; i < (int)t.size() ; i++){
    if(f && t[i] == 'A'){
      ans += t[i];
      f = false;
    }
    else if(!f && t[i] == 'Z'){
      ans += t[i];
      f = true;
    }
  }
  if(ans[ans.size()-1] == 'A') ans.erase(ans.begin() + (ans.size()-1));
  if(ans.size() == 0) cout << -1 << endl;
  else cout << ans << endl;
  
  return 0;
}

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

int main (){
	int n, m, x=0, y=0, z=0;
	
	cin >> n;
	for (int i=0; i<n; i++){
		cin >> m;
		if (m<=x){
			y = y+1;
			if (y>z) z=y;
		}
		else if (m>x) y=0;
		x=m;
	}
	
	cout << z << endl;
	
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
student=[list(map(int,input().split())) for i in range(n)]
point=[list(map(int,input().split())) for i in range(m)]

for a,b in student:
  length=10**10
  pn=0
  for j in range(m):
    c,d=point[j]
    if abs(a-c)+abs(b-d)<length:
      length=abs(a-c)+abs(b-d)
      pn=1+j
  print(pn)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>

#define INF (1 << 29)

using namespace std;

int fix(int num)
{
    return min(255, max( num, 0) );
}

int main()
{
    int N, M;
    while(cin >> N >> M, (N))
    {

        vector<int> in_C(M);
        for(auto& _c : in_C)
        {
            cin >> _c;
        }

        vector<int> in_X(N);
        for(auto& _x : in_X)
        {
            cin >> _x;
        }

        int dp[2][256];
        for(int i = 0; i < 256; i++)
        {
            dp[0][i] = dp[1][i] = INF;
        }

        for(int i = 0; i < M; i++)
        {
            int sub = fix(128 + in_C[i]);
            dp[0][sub] = (in_X[0] - sub) * (in_X[0] - sub);
        }

        for(int n = 1; n < N; n++)
        {
            for(int i = 0; i < 256; i++)
            {
                if(dp[0][i] == INF)continue;
                for(int j = 0; j < M; j++)
                {
                    int sub = fix(i + in_C[j]);
                    int nextScore = dp[0][i] + (in_X[n] - sub) * (in_X[n] - sub);
                    dp[1][sub] = min(dp[1][sub], nextScore);
                    /*
                    cout << sub << endl;
                    cout << dp[0][sub] << endl;
                    cout << pow( in_X[n] - sub, 2.0 ) << endl;
                    cout << endl;
                    //*/
                }
            }
            for(int i = 0; i < 256; i++)
            {
                dp[0][i] = dp[1][i];
                dp[1][i] = INF;
            }
        }

        int ans = INF;
        for(int i = 0; i < 256; i++)
        {
            ans = min(ans, dp[0][i]);
        }
        cout << ans << endl;

    }



    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e6+5;
char s[N];
ll sum;
int main()
{
    //ios::sync_with_stdio(false);
    scanf("%s",s);
    ll len=strlen(s);
    int t=0;
    //cout<<len<<endl;
    for(int i=len-1;i>=0;i--)
    {
        int a=s[i]-'0'+t;
        //t=0;
        //if(i!=0&&s[i]=='5'&&s[i-1]-'0'>=4) sum--;
        if(a>5)
        {
            sum+=(10-a);t=1;
        }
        else if(a==5)
        {
            if(a!=0&&s[i-1]-'0'>=5)
                sum+=(10-a),t=1;
            else
                sum+=a,t=0;
        }
        else
        {
            sum+=a;t=0;
        }
    }
    if(t==1)
        sum+=1;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);

ll a[N];
ll dp[N];
int n,k;

ll f(){
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=INF;
        for(int  j=1;j<=k;j++){
            if(i-j<0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    return dp[n-1];
}

void solve(int T){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    cout<<f();
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}




Measured memory_bytes: 5212
#include<iostream>
#include<deque>
using namespace std;
int main(){
 int a;
 deque<int>some;
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>a;
  if(i%2==n%2){
   some.push_back(a);
  }
  else{
   some.push_front(a);
  }
 }
 for(int x:some){
  cout<<x<<endl;
 }
 return 0;
}

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

int main()
{
    int n;
    cin>>n;
    float a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-1;i++)
    {
        a[i+1]=(a[i]+a[i+1])/2;
    }
    printf("%0.5f\n",a[n-1]);
}

Measured memory_bytes: 256
s = input()
q = int(input())
c = 0
l = []
r = []

for i in range(q):
  query = input()
  if query[0] == "1":
    c += 1
    a = l
    l = r
    r = a
  if query[0] == "2":
    if query[2] == "1":
      l.append(query[4])
    if query[2] == "2":
      r.append(query[4])
      
l = "".join(l)
l = l[::-1]
r = "".join(r)
      
if c%2 == 1:
  s = s[::-1]
  
print(l + s + r)

Measured memory_bytes: 5056
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[1] == 'B') s[1] = 'R';
    else s[1] = 'B';
    PRINT(s);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll H,W;
  cin >> H >> W;
  ll c[10][10];
  rep(i,10){
    rep(j,10){
      cin >> c[i][j];
    }
  }
  rep(k,10){
    rep(i,10){
      rep(j,10){
        c[i][j]=min(c[i][k]+c[k][j],c[i][j]);
      }
    }
  }
  ll ans=0;
  rep(i,H){
    rep(j,W){
      ll x;
      cin >> x;
      if(x!=-1){
        ans+=c[x][1];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import Data.Array.IO
import Control.Monad

main = do
  n <- readLn :: IO Int
  a <- getLine >>= return . (map read) . words :: IO [Int]
  arr <- newArray (0, 100000) 0 :: IO (IOArray Int Int)

  forM_ a $ \x -> do
    arrIncr arr x
    when (x>0) (arrIncr arr (x-1))
    when (x<100000) (arrIncr arr (x+1))


  print =<< return . maximum =<< getElems arr
    
  where
    arrIncr arr i = do
      r <- readArray arr i
      writeArray arr i (r+1)



Measured memory_bytes: 34812
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
     string[] str=Console.ReadLine().Split(' ');
      int[] input=str.Select(int.Parse).ToArray();
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int X=int.Parse(str[2]);
      if((A<=X)&&(X<=(A+B))){
        Console.WriteLine("YES");
      }else{
        Console.WriteLine("NO");
      }
    }
    
  }

}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

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

    vector<int> sumL(N+1);
    rep(i, N) sumL[i+1] = sumL[i] + abs((i==0? 0 : A[i-1]) - A[i]);

    vector<int> sumR(N+1);
    repr(i, N) sumR[i] = sumR[i+1] + abs(A[i] - (i==N-1 ? 0 : A[i+1]));

    rep(i, N) {
        int ans = sumL[i] + sumR[i+1];
        if (i == 0) {
            ans += abs(A[i+1]);
        } else if (i == N - 1) {
            ans += abs(A[i-1]);
        } else {
            ans += abs(A[i-1] - A[i+1]);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2432