akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure 
typedef tree<int, null_type, 
			less_equal<int>, rb_tree_tag, 
			tree_order_statistics_node_update> 
	indexed_set;  
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll> 
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/

ll findDiff(string a,string b){
	int len=a.length();
	ll cnt=0;
	rep(i,0,len){
		if(a[i]!=b[i]){
			cnt++;
		}
	}
	return cnt;
}

void solve(){
	string s,t;
	cin>>s;
	cin>>t;
	int lens=s.length();
	int lent=t.length();
	ll ans=inf;
	for(int i=0;i<=lens-lent;i++){
		string temp=s.substr(i,lent);
		ll loc=findDiff(temp,t);
		ans=min(ans,loc);
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3660
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<queue>
#include <cmath>
#include<algorithm>
#include<stack>
#include<map>
#include<ctime>
#define rep(i,n) for (int i=0;i<n;i++)
//#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    long long W;
    cin>>N>>W;
    long int sum=0;
    vector<long int> w(N),v(N);
    rep(i,N){
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    long int ans=0;
    const long long INF=10000000000;
    vector<vector<long long> > dp(N+1,vector<long long>(sum+1,INF));
    dp[0][0]=0;
    for (int i=1;i<N+1;i++){
        for (long int j=0;j<sum+1;j++){
            if (j>=v[i-1]) dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
            else dp[i][j]=dp[i-1][j];
            if (dp[i][j]<=W) ans=max(ans,j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 80256
ans = 0 #答え用変数

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
for i in range(N): #Aを１行ずつ読み込む
  A = list(map(int, input().split()))
  
  sum = 0 #sum AB
  
  for p in range(M):
    sum += (A[p] * B[p])
  if sum + C > 0:
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	priority_queue<ll> pq;
	while(1)
	{
		cin >> s;
		if(s[0]=='i')
		{
			cin >> n;
			pq.push(n);
		}else if(s[1]=='x')
		{
			cout << pq.top() << endl;
			pq.pop();
		}else
		{
			break;
		}
	}
}

Measured memory_bytes: 11312
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;
const double EPS = 1e-9;
void solve(){
	string s;
	cin >> s;
	if(s.back() == 's')s += "es";
	else s += 's';
	cout << s << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

int main() {
	vector<long long>A(3);
	for (long long i = 0; i < 3; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	if ((A.at(0) == A.at(1) && A.at(1) != A.at(2)) || (A.at(0) != A.at(1) && A.at(1) == A.at(2))) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

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

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    ll ans = 1;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        ans = lcm(ans, a);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  vector<int> a {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;
  k--;
  cout << a[k] << endl;
}

Measured memory_bytes: 256
class City:
    def __init__(self, index: int, prefecture: int, year: int):
        self.index = index
        self.prefecture = prefecture
        self.year = year
        self.id = ''

    def __lt__(self, other):
        if self.prefecture != other.prefecture:
            return self.prefecture < other.prefecture
        return self.year < other.year

    def __repr__(self):
        return '({}, {})'.format(self.prefecture, self.year)


N, M = map(int, input().split())

cities = []
for i in range(M):
    p, y = map(int, input().split())
    cities.append(City(i, p, y))

cities.sort()

p = 0
cnt = 1
for i in range(M):
    if p != cities[i].prefecture:
        p = cities[i].prefecture
        cnt = 1

    cities[i].id = '{:06d}'.format(p) + '{:06d}'.format(cnt)
    cnt += 1

cities.sort(key=lambda c: c.index)

for c in cities:
    print(c.id)


Measured memory_bytes: 47844
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N = inputI()
A = inputIL()

dic = [0]*N

for i in A:
  dic[i-1] += 1

for i in dic:
  print(i)

Measured memory_bytes: 94596
import java.util.*;

public class Main
{ 
	static String isDivisible(long n) 
	{ 
		long temp = n; 
		int sum = 0; 
		while (n != 0) 
		{ 
			int k = (int) n % 10; 
			sum += k; 
			n /= 10; 
		} 
		if (temp % sum == 0) 
			return "Yes"; 
	
		return "No"; 
	} 
	public static void main(String []args) 
	{ 
		Scanner sc=new Scanner(System.in);
		long n = sc.nextLong(); 
		System.out.println(isDivisible(n)); 
	} 
} 


Measured memory_bytes: 21716
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e6 + 5;                  

ll a, b;
ll neg;

int main() {
    
	cin >> a >> b;
	if ((a <= 0 && 0 <= b) || (a == 0 || b == 0)) {
		cout << "Zero";
		return 0;
	}
	if (a < 0 && b < 0) { 
		neg = (-b) - (-a) + 1;		
		if (neg % 2 == 0) cout << "Positive";
		else cout << "Negative";
	}
	else {
		cout << "Positive";
	}
	return 0;
}

Measured memory_bytes: 256
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
bit_count=Array.new(64,0)
a.each{|v|
  64.times{|i|bit_count[i]+=v[i]}
}

ans=0
strict_flag=true
63.downto(0){|i|
  coef=1<<i
  if strict_flag
    if k[i]==0
      ans+=coef*bit_count[i]
    else
      if 2*bit_count[i]>n
        ans+=coef*bit_count[i]
        strict_flag=false
      else
        ans+=coef*(n-bit_count[i])
      end
    end
  else
    ans+=coef*[n-bit_count[i],bit_count[i]].max
  end
}

puts ans

Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  ll H, W, N;
  cin >> H >> W >> N;

  ll ans = divceil(N, max(H, W));
  cout << ans << endl;
}

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

int main() {
    int N , M ;
    cin >> N >> M;
    vector<double>vec(N);
    for (int i = 0; i <N ; i++){
        cin >> vec.at(i) ;
    }
    double Y = 0;
    for (int i = 0; i < N ; i++ ){
        Y += vec.at(i);
    }
    double X = (Y/(4*M));
    int K = 0;
    for ( int i = 0; i<N ; i++){
        if (vec.at(i) >= X){
            K ++;
            }
        }
    if (K >= M) {
        cout << "Yes" << endl;
        }
    if (K < M){
        cout << "No" << endl;
    }       
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
    char name[16];
    int am,pm;
    while(scanf("%s %d %d",&name,&am,&pm)!=EOF){
        cout<<name<<" "<<am+pm<<" "<<am*200+pm*300<<"\n";
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, k, s;
    while(cin >> n >> k >> s, n){
        auto dp = make_v(k+1, 300, n+1, 0);
        dp[0][0][0] = 1;
        for (int i = 0; i < k; ++i) {
            for (int j = 0; j < 220; ++j) {
                for (int l = 0; l <= n; ++l) {
                    for (int m = l+1; m <= n; ++m) {
                        dp[i+1][j+m][m] += dp[i][j][l];
                    }
                }
            }
        }
        int ans = 0;
        for (int l = 1; l <= n; ++l) {
            ans += dp[k][s][l];
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3472
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 

int main() {
  ll n;
  cin >> n;
  ll a[n];
  int mod = 1000000007;
  ll sum = 0;
  for(int i = 0;i<n;i++){
    cin >> a[i];
  }
  ll b[n+1] = {};
  for(int i = 1;i<n+1;i++){
    b[i] = b[i-1] + a[i-1];
    //b[i] %= mod;
  }
  
  ll tmp;
  for(int i = 0;i<n;i++){
    tmp = (b[n]-b[i+1])%mod;
    sum += a[i]*tmp%mod;  
    sum%=mod;
  }

  cout << sum;
}

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

#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<long long, long long> pii;

const int MAXN = 1e6;
const int inf = 1e9 + 5;
const long double eps = 1e-8;

long long f(long long a) {
    long long b = 0;
    while (a % 2 == 0) {
        b++;
        a /= 2;
    }
    return b;
}

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

    int n, m;
    cin >> n >> m;
    vector<int> c(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        c[a]++, c[b]++;
    }

    for (int i = 0; i < n; i++) {
        if (c[i] % 2 != 0) {
            cout << "NO";
            return 0;
        }
    }

    cout << "YES";

    return 0;
}

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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int sum=0;
		int ave=0;
		int num=0;
		for(; sc.hasNext(); num++){
			String[] s=sc.nextLine().split(",");
			int m=Integer.parseInt(s[0]);
			int n=Integer.parseInt(s[1]);
			sum+=m*n;
			ave+=n;
		}
		println(""+sum);
		println(""+(int)((double)ave/num+0.5));
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=[0]*(n+1)
for i in range(m):
  a,b=map(str,input().split())
  a=int(a)
  if ac[a]==0:
    if b=='WA':
      wa[a]+=1
    else:
      ac[a]=1
print(sum(ac))
ans=0
for i in range(n+1):
  if ac[i]==1:
    ans+=wa[i]
print(ans)

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

string b[500];
signed main(){
	int a;cin>>a;
	for(int c=0;c<a;c++){
		cin>>b[c];
	}
bool d=false;
for(int c=0;c<a;c++){
	for(char e:b[c]){
		if(e=='#')d=true;
		}
	}
if(!d){puts("-1");return 0;}
int ans=1<<29;
int sum=0;
for(int i=0;i<a;i++){
	bool S=true;
	for(int j=0;j<a;j++){
		if(b[j][i]=='.')S=false;
		}
	if(!S)sum++;	
	}
for(int i=0;i<a;i++){
	int n=1;
	for(int j=0;j<a;j++){
		if(b[j][i]=='#'){n--;break;}
		}
	for(int j=0;j<a;j++){
		if(b[i][j]=='.')n++;
		}	
	ans=min(ans,n);	
	}		
cout<<ans+sum<<endl;	
}


Measured memory_bytes: 512
n,m = map(int,input().split())
h = list(map(int,input().split()))
ab=[]
for j in range(m):
    ab.append(list(map(int,input().split())))
lst=[1]*n
for a,b in ab:
    if h[a-1] > h[b-1]:
        lst[b-1] = 0
    elif h[a-1] < h[b-1]:
        lst[a-1] = 0
    else:
        lst[a-1] = 0
        lst[b-1] = 0
print(lst.count(1))

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

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

  int n;
  cin >> n;

  int a[n];
  map<int,int> mp, mp2;

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

  sort(a, a+n);

  for (int i = 0; i < n; ++i) for (int j = 2; j*a[i] <= a[n-1]; ++j) ++mp[j*a[i]];

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (mp[a[i]] || mp2[a[i]] > 1) continue;
    ++ans;
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 58180
#include<iostream>
 
using namespace std;
 
int n, y;
double maxmon;
int maxbank;
int b,r,t;
double tanri(int t){
  return 1+y*(double)t/100;
}
 
 
double fukuri(int t){
  double ans = 1;
  for(int i = 0; i < y; i++){
    ans *= 1+(double)t/100;
  }
  return ans;
}
int main(){
  while(cin >> n && n){
    maxmon = 0;
    cin >> y;
    for(int i = 0; i < n; i++){
      cin >> b >> r >> t;
      double now;
      if(t == 1) now = tanri(r);
      else now = fukuri(r);
      //cout << " now  " << now << endl;
      if(now > maxmon){
    maxmon = now;
    maxbank = b;
      }
    }
    cout << maxbank << endl;
  }
 
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define mod 998244353
using namespace std;

int read();
int M(int x) { return x >= mod ? x - mod : x; }
int fsp(int bs, int p) {
    int rt = 1;
    while (p) {
        if (p & 1)
            rt = 1ll * rt * bs % mod;
        bs = 1ll * bs * bs % mod, p >>= 1;
    }
    return rt;
}
int C2(int x) { return x * (x - 1) / 2; }
int fac[10004], caf[10004];
int C(int x, int y) { return 1ll * fac[x] * caf[y] % mod * caf[x - y] % mod; }
void init() {
    int lim = 10000;
    fac[0] = 1;
    for (int i = 1; i <= lim; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
    caf[lim] = fsp(fac[lim], mod - 2);
    for (int i = lim; i >= 1; --i) caf[i - 1] = 1ll * caf[i] * i % mod;
}

int rtt[20004], O[20004], ny;
void getrtt(int w, int len) {
    for (int i = 1; i < len; ++i) rtt[i] = rtt[i >> 1] >> 1 | ((i & 1) << w);
    for (int l = 2; l <= len; l <<= 1) O[l] = fsp(3, (mod - 1) / l);
    ny = fsp(len, mod - 2);
}

struct Poly {
    int x[20004];
    int &operator[](int p) { return x[p]; }
    void ntt(int len) {
        for (int i = 1; i < len; ++i)
            if (rtt[i] > i)
                swap(x[rtt[i]], x[i]);
        for (int l = 2; l <= len; l <<= 1) {
            for (int i = 0, m = l >> 1; i < len; i += l) {
                for (int j = i, tO = 1, t; j < i + m; ++j) {
                    t = 1ll * tO * x[j + m] % mod, tO = 1ll * tO * O[l] % mod;
                    x[j + m] = M(x[j] - t + mod), x[j] = M(x[j] + t);
                }
            }
        }
    }
    void idft(int len) {
        ntt(len), reverse(x + 1, x + len);
        for (int i = 0; i < len; ++i) x[i] = 1ll * x[i] * ny % mod;
    }
} f, g, tf;

int n, m;
int main() {
    n = read(), m = read();
    init();
    int w = 1, len = 2;
    while (len < 2 * n + 1) len <<= 1, ++w;
    for (int i = 1; i <= n; ++i) g[i] = caf[i + 2];
    getrtt(w - 1, len), g.ntt(len);
    tf[0] = f[0] = 1;
    for (int i = 1; i <= m; ++i) {
        f.ntt(len);
        for (int j = 0; j < len; ++j) f[j] = 1ll * f[j] * g[j] % mod;
        f.idft(len);
        for (int j = 0; j <= n; ++j) {
            tf[j] = M(1ll * f[j] * fac[j + 2] % mod + 1ll * tf[j] * (1 + j + C2(j)) % mod);
            f[j] = 1ll * tf[j] * caf[j] % mod;
        }
        for (int j = n + 1; j < len; ++j) f[j] = 0;
    }
    int res = 0;
    for (int i = 0; i <= n; ++i) res = M(res + 1ll * C(n, i) * tf[i] % mod);
    printf("%d\n", res);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


int main()
{
    string s,t;
    cin >> s >> t;
    int n = SZ(s);
    int m = SZ(t);
    int res = m;
    rep(i,n-m+1) {
        string cur = s.substr(i,m);
        int cnt = 0;
        rep(j,m) {
            if(t[j] != cur[j]) cnt++;
        }
        chmin(res, cnt);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
A, B = map(int, input().split())
S = input()
S_A, S_B = S[:A], S[A + 1:]
if len(S_A) == A and len(S_B) == B and S_A.isdigit() and S_B.isdigit() and \
   S[A] == '-':
    print('Yes')
else:
    print('No')


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

ll gcd(ll a, ll b) {
    if (a % b == 0) {
        return (b);
    } else {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

    a--;

    put((b - (b / c + b / d - b / lcm(c, d))) - (a - (a / c + a / d - a / lcm(c, d))));
}

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

using namespace std;

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

    bool f = true;
    for (int i = 1; i < S.size(); i++) if (S[i - 1] == S[i]) f = false;

    cout << (f ? "Good" : "Bad") << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s.size()==2){
        if(s[0]==s[1]){
            cout<<1<<" "<<2<<endl;
        }
        else{
            cout<<-1<<" "<<-1<<endl;
        }
        return 0;
    }
    int x=-1,y=-1;
    for(int i=0;i<s.size()-2;i++){
        if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
            x=i+1;
            y=i+3;
            break;
        }
    }
    cout<<x<<" "<<y<<endl;
}


Measured memory_bytes: 512
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var n = sc.nextInt();
        var d = sc.ArrayInt(n);
        d = d.OrderBy(i => i).ToArray();
        WriteLine(Math.Abs(d[n / 2 - 1] - d[n / 2]));
    }
}


class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 21856
import sys 

K = int(input())

if K <= 0:
    sys.exit(0)

step = 1 
snuke = 1 

while K > 0:
    if step < snuke/sum(map(int, str(snuke))):
        snuke += 9 * step
        step *= 10
    else:
        print(snuke)
        snuke += step
        K -= 1

Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#define MAX(x,y) (((x)>(y))?(x):(y))

int x=0,i=0,j,d[500],m=0,l=0;
char s[500][36];

int main(){
    memset(d,0,sizeof(d));
    while(scanf("%s",s[x])!=EOF){
        x++;j=0;
        for(i=0;i<x-1;i++){
            if(strcmp(s[i],s[x-1])==0)d[i]++,j=1;
            m=MAX(m,d[i]);
            l=MAX(l,strlen(s[i]));
        }
        if(j==1)x--,j=0;
    }
    for(i=0;i<=x;i++)if(d[i]==m)printf("%s ",s[i]);
    for(i=0;i<=x;i++)if(strlen(s[i])==l)printf("%s\n",s[i]);
    
    return 0;
}


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

using namespace std;

int l[2000][2000];
int u[2000][2000];
int d[2000][2000];
int r[2000][2000];
int ans[2000][2000];


int main() {

    int h,w;
    cin>>h>>w;
    string s[h];
    for(int i=0;i<h;i++)
    cin>>s[i];
    
for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
        if(j==0)
        l[i][j]=0;
        else 
        {
            
            if(s[i][j-1]=='#'||s[i][j]=='#')
            l[i][j]=0;
            else 
            l[i][j]=l[i][j-1]+1;
            
        }
    }
}
    
    for(int i=0;i<h;i++)
    {
        for(int j=w-1;j>=0;j--)
        {
            if(j==w-1)
            r[i][j]=0;
            else
            {
                if(s[i][j]=='#'||s[i][j+1]=='#')
                r[i][j]=0;
                else
                r[i][j]=r[i][j+1]+1;
                
            }
        }
    }
    
    for(int j=0;j<w;j++)
    {
        for(int i=h-1;i>=0;i--)
        {
            if(i==h-1)
            d[i][j]=0;
            else
            {
                if(s[i][j]=='#'||s[i+1][j]=='#')
                d[i][j]=0;
                else
                d[i][j]=d[i+1][j]+1;
                
            }
        }
    }
    for(int j=0;j<w;j++)
    {
        for(int i=0;i<h;i++)
        {
            if(i==0)
            u[i][j]=0;
            else
            {
                if(s[i][j]=='#'||s[i-1][j]=='#')
                u[i][j]=0;
                else
                u[i][j]=u[i-1][j]+1;
            }
        }
    }
    
    int max=-1;
  for(int i=0;i<h;i++)
  {
      for(int j=0;j<w;j++)
      {
          ans[i][j]=l[i][j]+r[i][j]+d[i][j]+u[i][j];
        if(ans[i][j]>max)
          max=ans[i][j];
      }
  }
  
  
    cout<<max+1;
    /*
    
        
for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
cout<<l[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;

    for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
cout<<r[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
cout<<d[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;for(int i=0;i<h;i++)
{
    for(int j=0;j<w;j++)
    {
cout<<u[i][j]<<" ";
}
cout<<endl;
}
cout<<endl;
    
    
    */
    
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= (n); ++i){
    int x = i*1.08;
    if(n==x) {ans = i; break;}
    else continue;
  }
  if(ans>0){
    cout << ans << endl;
  }
  else cout << ":(" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,m,a[N],cnt[N],num[N],ans;
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++;
	for (int i=1;i<=n;i++) num[max(i-cnt[i]+1,1)]++,num[i+1]--;
	for (int i=1;i<=n;i++){
        num[i]+=num[i-1];
        if (!num[i]) ans++;
	}
    while (m--){
        int x,y;
        scanf("%d%d",&x,&y);
        int v=a[x];
        if (v-cnt[v]+1>=1){
            if (num[v-cnt[v]+1]==1) ans++;
            num[v-cnt[v]+1]--;
        }
        cnt[v]--;
        a[x]=y;
        cnt[y]++;
        if (y-cnt[y]+1>=1){
            num[y-cnt[y]+1]++;
            if (num[y-cnt[y]+1]==1) ans--;
        }
        printf("%d\n",ans);
    }
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;
int main() {
	int n, a[20], b[50], c[50], sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n - 1; i++) {
		cin >> c[i];
	}
	sum = b[a[0] - 1];
	for (int i = 1; i < n; i++) {
		sum += b[a[i] - 1];
		if (a[i] == a[i - 1] + 1)sum += c[a[i - 1] - 1];
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define M 100010


int main(){
    IOS;
     
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    multiset<pii>s;
    s.insert({a[n-2],a[n-1]});
    s.insert({a[n-2],a[n-1]});
    ll ans=a[n-1];
    for(ll i=n-3;i>=0;--i){
    	auto it=s.end();it--;
    	pii p=*it; s.erase(it);
    	ans+=p.fi;
    	ll x=p.fi,y=p.se,z=a[i];
    	s.insert({min(y,z),max(y,z)});
    	s.insert({min(x,z),max(x,z)});
    }
    cout<<ans;
     
     
     
    return 0;
}


Measured memory_bytes: 17700
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <math.h>
#include <string>
#define ll long long
#define ull unsigned long long
#define make(type,x) type x; cin>>x
#define make2(type,x,y) type x,y; cin>>x>>y
#define fr(x,y) for(long long x=0;x<y;x++)
#define makevec(x,y,n) vector <x> y(n); for(ll i=0;i<n;i++) cin>>y[i]
#define M (ll)1000000007
#define MM (ll) 1e8
#define INF (ll) 1e18

# define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
bool sortbysec(const pair <ll,ll> &a,const pair <ll,ll> &b){
    return a.second<b.second;
}

struct cmp {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		int lena = a.second - a.first + 1;
		int lenb = b.second - b.first + 1;
		if (lena == lenb) return a.first < b.first;
		return lena > lenb;
	}
};
struct c_h {
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        x ^= FIXED_RANDOM;
        return x ^ (x >> 16);
    }
};

ll calcpow(ll x, ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = calcpow(x, y / 2);
    if (y % 2 == 0)
        return temp * temp;
    else
    {
        if(y > 0)
            return x * temp * temp;
        else
            return (temp * temp) / x;
    }
}
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b,a%b);

}
ll egcd(ll a, ll b, ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1;
    ll y1;
    ll g=egcd(b,a%b,x1,y1);
    x=y1;
    y=x1-y1*(a/b);
    return g;
}


bool isprime(ll a){
bool flag=1;
for(ll i=2;i*i<=a;i++){
    if(a%i==0) {flag=0; break;}
}
return flag;
}



int main(){
    IOS;
    make(ll,n);
    vector <ll> ans;
    while(n){
        ll a=(n-1)%26;
        //cout<<n<<" "<<a<<" ";
        ans.push_back(a);
        n=(n-a)/26;
    }
    reverse(ans.begin(),ans.end());
    for(auto x : ans) cout<<(char)('a'+x);
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }


int main(){
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define mod         1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  freopen("gout.txt", "w", stdout);
 
#endif
}

void solve()
{
  int n;
  cin >> n;
  cout<<(n*(n-1))/2;
}
 
 
int32_t main()
{
  pr_init();
  fastio;
 
  auto start = high_resolution_clock::now();
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  // cout << "Time taken by function: "
  //       << duration.count() << " microseconds" << endl;
 
}
 

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

#define MAX 2000001
#define VMAX 10001

int main(){
  int i,j,n=0;
  unsigned short *A,*B;
  int C[VMAX];
  scanf("%d",&n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= VMAX-1; i++ ) C[i] = 0;
  
  for(i=1;i<=n;i++){
      scanf("%d",&A[i]);
      C[A[i]]++;
  }
  
  for(i=1;i<=VMAX-1;i++){
      C[i]=C[i]+C[i-1];
  }

  for(j=1;j<=n;j++){    
      B[C[A[j]]] = A[j];
      C[A[j]]--;
  }

  for(i=1;i<n+1;i++){
      if(i<n){
        printf("%d ",B[i]);
      }
      else{
        printf("%d\n",B[i]);
      }
    }
  return 0;
}

Measured memory_bytes: 8456
/**
 * Author: Martin Leshko (leshko.martin@gmail.com)
 */

#include <bits/stdc++.h>
#define F0R(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, n) for (int i = 1; i <= (int)(n); i++)
#define trav(i, a) for (auto& i: a)
#define sz(x) (int)x.size()
#define psb push_back
template<class T> void re(T& x) { std::cin >> x; }
template<class T, class... Ts> void re(T& t, Ts&... ts) { re(t); re(ts...); }
void pr(int x) { std::cout << x; }
void pr(long long x) { std::cout << x; }
void pr(float x) { std::cout << x; }
void pr(double x) { std::cout << x; }
void pr(char x) { std::cout << x; }
void pr(const char* x) { std::cout << x; }
void pr(const std::string& x) { std::cout << x; }
template<class T> void pr(const T& x);
template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {  pr(t); pr(ts...); }
void ps() { std::cout << "\n"; }

using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;

int main() {
  int n; string s; re(n, s);
  trav(i, s) i -= 'A';
  trav(i, s) i = (i + n) % 26;
  trav(i, s) i += 'A';
  pr(s);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,m;
int a[100005];

long long seglazy1[262144];     // general movement
long long seglazy2[262144];     // linear thing
int seg1[262144];
int seg2[262144];

void seglazy(int i)
{
    if (i<131072) {
        if (seglazy1[i]) {
            seglazy1[i*2]+=seglazy1[i];
            seglazy1[i*2+1]+=seglazy1[i];
            seglazy1[i]=0;
        }
        if (seglazy2[i]) {
            seglazy2[i*2]+=seglazy2[i];
            seglazy1[i*2]+=seglazy2[i]*((seg2[i]-seg1[i]+1)/2);
            seglazy2[i*2+1]+=seglazy2[i];
            seglazy2[i]=0;
        }
    }
}

void segadd1(int i,int u,int v,int w)
{
    if (v<seg1[i] || seg2[i]<u) return;
    if (u<=seg1[i] && seg2[i]<=v) {
        seglazy1[i]+=w;
        return;
    }
    seglazy(i);
    segadd1(i*2,u,v,w);
    segadd1(i*2+1,u,v,w);
}

void segadd2(int i,int u,int v)
{
    if (v<seg1[i] || seg2[i]<u) return;
    if (u<=seg1[i] && seg2[i]<=v) {
        seglazy1[i]+=v-seg2[i];
        seglazy2[i]++;
        return;
    }
    seglazy(i);
    segadd2(i*2,u,v);
    segadd2(i*2+1,u,v);
}

long long ans;

int main()
{
    #ifdef NOT_DMOJ
    freopen("data.txt","r",stdin);
    #endif // NOT_DMOJ
    // setup
    for (int i=0; i<131072; i++) seg1[i+131072]=seg2[i+131072]=i;
    for (int i=131071; i; i--) {
        seg1[i]=seg1[i*2];
        seg2[i]=seg2[i*2+1];
    }
    // get info
    scanf("%d%d",&n,&m);
    for (int i=0; i<n; i++) {
        scanf("%d",a+i);
        a[i]--;
    }
    for (int i=1; i<n; i++) {
        // do the jump a[i-1] to a[i]
        if (a[i-1]<a[i]) {
            // generic
            //printf("generic %d %d\n",a[i-1],a[i]);
            segadd1(1,a[i]+1,m-1,a[i]-a[i-1]);
            segadd1(1,0,a[i-1],a[i]-a[i-1]);
            segadd2(1,a[i-1]+1,a[i]+1);
        }
        else if (a[i-1]>a[i]) {
            // inverted
            //printf("inverted %d %d\n",a[i-1],a[i]);
            segadd1(1,a[i]+1,a[i-1],a[i]+m-a[i-1]);
            segadd2(1,0,a[i]+1);
            segadd2(1,a[i-1]+1,m-1);
            segadd1(1,a[i-1]+1,m-1,a[i]+2);
        }
    }
    // prop. and get best answer
    for (int i=1; i<131072; i++) seglazy(i);
    ans=seglazy1[131072];
    for (int i=1; i<m; i++) {
        if (ans>seglazy1[131072+i]) {
            ans=seglazy1[131072+i];
        }
    }
    printf("%lld\n",ans);
    //for (int i=0; i<m; i++) printf("%d is %lld\n",i,seglazy1[i+131072]);
}


Measured memory_bytes: 6656
package main

import "fmt"

func main(){
	var a,b,c,k int
	fmt.Scan(&a,&b,&c,&k)
	if k <= a {
		fmt.Println(k)
	} else if k <= a+b {
		fmt.Println(a)
	} else if k <= a+b+c {
		fmt.Println(a-(k-(a+b)))
	} else {
		fmt.Println(a-c)
	}
}


Measured memory_bytes: 1756
import math
a = 0
b = 0
c = 0
d = 0
input_str = input().split()
input_str_list = []

## 少数を省く
for x in input_str:
    try:
       input_str_list.append(int(x))
    except:
      print("NO")
      exit()

for i in range(len(input_str_list)):
  if input_str_list[i] == 1:
    a+=1
  elif input_str_list[i] == 9:
    b+=1
  elif input_str_list[i] == 7:
    c+=1
  elif input_str_list[i] == 4:
    d+=1
if a==1 and b==1 and c==1 and d==1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int first_digit(int i) {
    while(i > 9) {
        i = (i - i%10)/10;
    }
    return i;
}
int main() {
    int n;
    cin >> n;
    int arr[10][10];
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            arr[i][j] = 0;
        }
    }

    for (int i=1; i<=n ; i++) {
        (arr[i%10][first_digit(i)])++;
    }
    int ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            ans += arr[i][j] * arr[j][i];
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
	string s;
    cin >> s;
    vector<string> t{"KIH", "B", "R"};
    for (int bit = 0; bit < (1<<4); ++bit) {
        string target = "";
        for (int i = 0; i < 4; ++i) {
            if(bit & (1 << i)) {
                target += "A";
            }
            if(i < 3) target += t[i];
        }
        if(s == target) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
}


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

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

#define MOD 1000000007

int main(void) {
    ll H;
    ll count = 1;
    stack<ll> s;
    cin >> H;
    while(H > 1) {
        H /= 2;
        s.push(H);
    }
    for(ll i = 0;i < s.size();i++) count = 2 * count + 1;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int n;
    ll sum = 0, a = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int k;
        scanf("%d",&k);
        v.emplace_back(-k);
        sum -= k;
    }
    for (int j = 0; j < n; ++j) {
        int k;
        scanf("%d",&k);
        v[j] += k;
        sum += k;
    }
    for (int i = 0; i < n; ++i) if(v[i] > 0) a += (v[i]+1)/2;
    cout << (sum >= a ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s,a,b;
int32_t main(){
CODE_START;
cin>>s;
string x=s;
reverse(x.begin(),x.end());
if(x!=s){
    cout<<"No"<<endl;
     return 0;
}
a="";
n=s.size();
for(ll i=0;i<n/2;i++){
    a=a+s[i];
}
b="";
for(ll i=n/2+1;i<n;i++)
{
    b=b+s[i];
}
x=a;
reverse(x.begin(),x.end());
if(x!=a){
    cout<<"No"<<endl;
    return 0;
}
x=b;
reverse(x.begin(),x.end());
if(x!=b){
    cout<<"No"<<endl;
    return 0;
}
cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dp[1010101][2];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    reverse(S.begin(), S.end());
    int N = S.size();
    REP(i,1010101) dp[i][0] = dp[i][1] = INF;
    dp[0][0] = 0;
    int a = 0;
    REP(i,N){
        a = S[i] - '0';
        //cout << dp[i+1][0] << " " << dp[i+1][1] << endl;
        chmin(dp[i+1][0], min(dp[i][0], dp[i][1]) + a);
        chmin(dp[i+1][1], min(dp[i][0] + 11 - a, dp[i][1] + 9 - a));
        //cout << dp[i+1][0] << " " << dp[i+1][1] << endl;
    }
    //cout << a << endl;
    //dp[N+1][0] = min(dp[N-1][0] + a, dp[N-1][1] + a + 1);
    //dp[N+1][1] = min(dp[N-1][0] + 10 - a, dp[N-1][1] + 9 - a);
    cout << min(dp[N][0], dp[N][1]) << endl;
    //cout << dp[N+1][0] << " " << dp[N+1][1] << endl;
}


Measured memory_bytes: 9244