akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=17000,Mo=998244353;
int fac[N],inv[N],A[N],B[N],rev[N],f[N];
inline int Pow(int x,int y) {
    int ret=1;
    while(y) {
	if(y&1) ret=1LL*ret*x%Mo;
	x=1LL*x*x%Mo,y>>=1;
    }
    return ret;
}
inline void NTT(int *a,int n,int f) {
    for(int i=0;i<n;i++) if(i<rev[i]) swap(a[i],a[rev[i]]);
    for(int i=1;i<n;i<<=1) {
	int wn=Pow(3,(Mo-1)/(i<<1)),x,y;
	for(int j=0;j<n;j+=i<<1)
	    for(int k=0,w=1;k<i;k++,w=1LL*w*wn%Mo) {
		x=a[j+k],y=1LL*a[j+k+i]*w%Mo;
		a[j+k]=(x+y)%Mo,a[j+k+i]=(x-y)%Mo;
	    }
    }
    if(f==1) return;
    reverse(a+1,a+n);
    int Inv=Pow(n,Mo-2);
    for(int i=0;i<n;i++) a[i]=1LL*a[i]*Inv%Mo;
}
inline int C(int n,int m) {
    if(n<m) return 0;
    return 1LL*fac[n]*inv[m]%Mo*inv[n-m]%Mo;
}
int main() {
    int n,m,s,L,ans=0;
    cin>>n>>m>>s>>L;
    for(s=1,L=0;s<=n+n;s<<=1) L++;
    for(int i=0;i<s;i++) rev[i]=((rev[i>>1]>>1)|((i&1)<<L-1));
    fac[0]=1;
    for(int i=1;i<=n+2;i++) fac[i]=1LL*fac[i-1]*i%Mo;
    inv[n+2]=Pow(fac[n+2],Mo-2);
    for(int i=n+2;i;i--) inv[i-1]=1LL*inv[i]*i%Mo;
    for(int i=1;i<=n;i++) B[i]=inv[i+2];
    NTT(B,s,1),f[0]=1;
    for(int i=1;i<=m;i++) {
	memset(A,0,sizeof(A));
	for(int j=0;j<=n;j++) A[j]=1LL*f[j]*inv[j]%Mo;
	NTT(A,s,1);
	for(int j=0;j<s;j++) A[j]=1LL*A[j]*B[j]%Mo;
	NTT(A,s,-1);
	for(int j=0;j<=n;j++)
	    f[j]=(1LL*A[j]*fac[j+2]+1LL*f[j]*(C(j+1,2)+1))%Mo;
    }
    for(int i=0;i<=n;i++) ans=(ans+1LL*C(n,i)*f[i])%Mo;
    cout<<(ans+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<set>
#include<cmath>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll INF =  1LL << 60;
const int inf = 1 << 30;
int n, m, x, y, q, d; ll z, w = 0, sum = 1; int ans = 0;
const int MAX = 510000;
const int MOD = 1000000007;
int main(void) {
	cin >> n;
	if (n == 1) cout << 1 << endl;
	else if (n < 4) cout << 2 << endl;
	else if (n < 8) cout << 4 << endl;
	else if (n < 16) cout << 8 << endl;
	else if (n < 32) cout << 16 << endl;
	else if (n < 64) cout << 32 << endl;
	else  cout << 64 << endl;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  while(n--){
    int dtct[10][10];
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, 0, 0, 1};
    for(int i = 0; i < 10; i++){
      for(int j = 0; j < 10; j++){
	cin >> dtct[i][j];
      }
    }
    
    for(int i = 0; i < 1 << 10; i++){
      int axi[10][10] = {{0}};
      int tmp[10][10] = {{0}};
      for(int j = 0; j < 10; j++){
	axi[0][j] = (i >> j) & 1;
	if(axi[0][j] == 0) continue;
	for(int k = 0; k < 4; k++){
	  int nx = j + dx[k], ny = dy[k];
	  if(nx < 0 || 10 <= nx || ny < 0 || 10 <= ny) continue;
	  tmp[ny][nx]++;
	}
      }
      for(int j = 1; j < 10; j++){
	for(int k = 0; k < 10; k++){
	  if((dtct[j-1][k]+tmp[j-1][k])%2 == 1){
	    axi[j][k] = 1;
	    for(int l = 0; l < 4; l++){
	      int nx = k + dx[l], ny = j + dy[l];
	      if(nx < 0 || 10 <= nx || ny < 0 || 10 <= ny) continue;
	      tmp[ny][nx]++;
	    }
	  }
	}
      }
      bool flag = true;
      for(int j = 0; j < 10; j++){
	if((tmp[9][j]+dtct[9][j])%2 == 1) flag = false;
      }
      if(flag){
	for(int j = 0; j < 10; j++){
	  for(int k = 0; k < 10; k++) cout << axi[j][k] << (k == 9 ? "\n":" ");
	}
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(1<<n),mx(1<<n),sec(1<<n),mx_ind(1<<n,-1),sec_ind(1<<n,-1);
    for(int i=0;i<(1<<n);i++){
        cin >> a[i];
        mx[i] = a[i];
        mx_ind[i] = i;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<n);j++){
            if(j&(1<<i)){
                if(mx[j]<mx[j-(1<<i)]){
                    if(mx[j]<sec[j-(1<<i)]){
                        mx[j] = mx[j-(1<<i)];
                        mx_ind[j] = mx_ind[j-(1<<i)];
                        sec[j] = sec[j-(1<<i)];
                        sec_ind[j] = sec_ind[j-(1<<i)];
                    }else{
                        sec[j] = mx[j];
                        sec_ind[j] = mx_ind[j];
                        mx[j] = mx[j-(1<<i)];
                        mx_ind[j] = mx_ind[j-(1<<i)];
                    }
                }else if(mx[j]==mx[j-(1<<i)]){
                    if(mx_ind[j]==mx_ind[j-(1<<i)]){
                        if(sec[j]<=sec[j-(1<<i)]){
                            if(sec_ind[j]!=sec[j-(1<<i)]){
                                sec[j] = sec[j-(1<<i)];
                                sec_ind[j] = sec_ind[j-(1<<i)];
                            }
                        }
                    }else{
                        sec[j] = mx[j-(1<<i)];
                        sec_ind[j] = mx[j-(1<<i)];
                    }
                }else if(sec[j]<mx[j-(1<<i)]){
                    sec[j] = mx[j-(1<<i)];
                    sec_ind[j] = mx_ind[j-(1<<i)];
                }
            }
        }
    }
    vector<int>dp(1<<n);
    dp[0] = 0;
    for(int i=1;i<(1<<n);i++){
        dp[i] = mx[i]+sec[i];
        dp[i] = max(dp[i],dp[i-1]);
        cout << dp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 9216
def main():
    N = int(input())
    A = [int(input()) for i in range(N)]
    ans = 0
    for i in range(N):
        ans += A[i]//2
        A[i] %= 2
        if i < N - 1 and A[i] > 0 and A[i+1] > 0:
            ans += 1
            A[i] -= 1
            A[i+1] -= 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 49752
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  typedef vector<INTV> Graph;
  int N, a, b; cin >> N;
  Graph G(N);
  REP(i, N-1){
    cin >> a >> b;
    a--; b--;
    G[a].eb(b); G[b].eb(a);
  }
  int mx = 0, mxidx = 0;
  REP(i, N){
    if(G[i].size() > mx){
      mx = G[i].size(); mxidx = i;
    }
  }
  pque<int> C;
  int sum = 0;
  REP(i, N){
    int c; cin >> c;
    C.push(c);
    sum += c;
  }
  sum -= C.top(); cout << sum << endl;
  
  INTV ans(N, -1);
  queue<int> que; que.push(mxidx);
  while(!que.empty()){
    int pos = que.front(); que.pop();
    ans[pos] = C.top(); C.pop();
    REP(i, G[pos].size()){
      int nx = G[pos][i];
      if(ans[nx] == -1) que.push(nx);
    }
  }

  REP(i, N) cout << ans[i] << ' ';
  cout << endl;
}

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

long long myabs(long long X);

int main(){
    long long X, D, K;
    long long X_abs, ans;
    std::cin >> X >> K >> D;

    X_abs = myabs(X);
    if((X_abs - X_abs%D)/D >= K ){
        //限界まで近づけばいいだけの場合
        ans = X_abs - D * K;
    }else{
        if((K - (X_abs - X_abs%D)/D)%2 == 0){
            ans = X_abs%D;
            // std::cout << (K - (X_abs - X_abs%D)/D);
            // std::cout << X_abs << "\n";
            // std::cout << "konobunki?";
        }else{
            ans = D - X_abs%D;
        }
    }
    std::cout << ans;
}

long long myabs(long long X){
    if(X < 0){
        return -X;
    }else
    {
        return X;
    }
    
}

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

using namespace std;
typedef long long ll;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {

    cin.tie(0);
    cin.sync_with_stdio(0);
}

ll n, m;
int freq[26];

int main() {
    fast();
    int n;
    cin>>n;
    ll arr[n];
    ll sum=0;
    for (int i = 0; i < n; ++i) {
                cin>>arr[i];
                sum+=arr[i];
    }
    int m;cin>>m;
    while (m--){
        ll a,b;cin>>a>>b;
        cout<<sum-arr[a-1]+b<<endl;
    }
}

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

using namespace std;

int main(){
  long long n, k;
  cin>>n>>k;
  
  if(n <= k){
    n = min(n, abs(n - k));
    cout<<n<<'\n';
  } else {
    long long rem = n - k;
    rem = (rem / k) * k;
    n -= rem;
    n -= k;
    cout<<min(abs(n - k), n)<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, d = rm()
cnt = 0
for _ in range(n):
  x, y = rm()
  if (x**2 + y**2) ** 0.5 <= d:
    cnt += 1
print(cnt)








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

	int next(int arr[],int arr1[],int n){
		int cnt,i;
		int res=0;
       
	   do{
	   	 cnt=0;
    		for(i=0;i<n;i++)
    	    { 
    		  if(arr1[i]==arr[i])
    		   cnt++;
		    }
		if(cnt==n)
		break;
		res++;
	}while(next_permutation(arr,arr+n));
	return res;
  }

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(0);
	int n,i;
	cin>>n;
	int arr[n], arr1[n];
	
	
	for(i=0;i<n;i++)
	cin>>arr[i];
	
	for(i=0;i<n;i++)
	cin>>arr1[i];
	int count=0;
	for(i=0;i<n;i++)
	{
		if(arr[i]==arr1[i]){
	     count++;
	      if(count==n){
	   	   cout<<"0"<<endl;
	   	    break;
	   }
	   continue;
	  }
	  
		if(arr[i]<arr1[i]){		
		cout<<next(arr,arr1,n)<<endl;
	     break;
	    }
	    else{
	       cout<<next(arr1,arr,n)<<endl;
         	break;	
    	}
   }
}
	
	




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

lint N;
lint ans;

void dfs(string n,int L){
    if(L>=10) return;
    lint num=stoll(n);
    if(num<=N){
        bool che[3]={};
        rep(i,L){
            if(n[i]=='3') che[0]=true;
            if(n[i]=='5') che[1]=true;
            if(n[i]=='7') che[2]=true;
        }
        if(che[0]&&che[1]&&che[2]) ans++;
    }
    dfs(n+'3',L+1);
    dfs(n+'5',L+1);
    dfs(n+'7',L+1);
}

int main(void){
    cin >> N;
    dfs("3",1);
    dfs("5",1);
    dfs("7",1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int n;
ll a[maxn];

struct node {
	ll val, num;
} last[maxn];

bool cmp(ll a, ll b) {
	return a > b;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1, cmp);
	ll ans = 0, i = 2, head = 1, tail = 0;
	last[++tail] = (node){a[1], 1};
	while (i <= n) {
		ans += last[head].val; last[head].num--;
		if (last[head].num == 0) head++;
		if (a[i] != last[tail].val || i == 2) last[++tail] = (node){a[i], 2};
		else last[tail].num += 2;
		i++;
	}
	printf("%lld\n", ans);
	return 0;
}

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


int main(void){

int x,y,temp;
int testX [3000];
int testY[3000];


    for(int i = 1; i < 3000; i++){

       cin >> x>>y;
       testX[i] = x;
       testY[i] = y;
       
       if(testX[i] > testY[i]){
           
           temp = testX[i];
           testX[i] = testY[i];
           testY[i] = temp;
       }
       if(testX[i] == 0 && testY[i] == 0)
       break;
       
       cout << testX[i] << " "  << testY[i] << endl;
    }
}


Measured memory_bytes: 3068
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}

template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

// }}}
const int MAX_N = 3005;
int N, T, dp[MAX_N][MAX_N];
vector<PII> v;
void input() {
    RI(N, T);
    REP(i, N) {
    	int a, b;
    	RI(a, b);
    	v.emplace_back(a,b);
    }
}

void solve() {
	int ans = 0;
	sort(ALL(v));
	REP1(i, 1, N) {
		REP1(j, 1, T) {
			dp[i][j] = dp[i-1][j];
			if(j>=v[i-1].first) dp[i][j] = max(dp[i][j], dp[i-1][j-v[i-1].first] + v[i-1].second);
			ans = max(ans, dp[i-1][j-1] + v[i-1].second);
		}
	}

	printf("%d\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}


Measured memory_bytes: 35584
N,K = map(int,input().split())
AB = []
for i in range(N):
    a,b = map(int,input().split())
    AB.append((a,b))

AB.sort()

cnt = 0
for ab in AB:
    a,b = ab
    cnt += b
    if cnt >= K:
        print(a)
        break


Measured memory_bytes: 16940
from itertools import combinations

n = int(input())
len_list = list(map(int, input().split()))
len_list = sorted(len_list)
#print(len_list)

per_len = list(combinations(len_list, 3))
#print(per_len)
count = 0

for i in range(len(per_len)):
    if per_len[i][2] == per_len[i][0] or per_len[i][1] == per_len[i][2] or per_len[i][0] == per_len[i][1]:
        pass
    
    else:
        if per_len[i][2] < per_len[i][0] + per_len[i][1] :
            count += 1
            #print(i)
            #print(count)

print(count)

Measured memory_bytes: 20612
//
// Created by Huang,Zhiqiang on 2018/8/20.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

ll k;
string s;

int main() {
    cin >> s >> k;
    ll i = 1;
    for (; i <= s.size(); i++) {
        if (s[i - 1] != '1') {
            break;
        }
    }
    if (k < i) {
        cout << '1' << endl;
    } else {
        cout << s[i - 1] << endl;
    }
}

Measured memory_bytes: 256
N,K = map(int, input().split())
# p[i]での出目の期待値
P = [(int(i) + 1) / 2 for i in input().split()]

from itertools import accumulate

P = [0] + list(accumulate(P))

ans = 0
for i in range(N - K + 1):
    ans = max(ans, P[i + K] - P[i])

print(ans)

Measured memory_bytes: 23524
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        int p[] = new int[n];
        int i = 0;
        int count = 0;
		// 出力
      for(i = 0; i < n; i++){
        p[i] = sc.nextInt();
      }
	  for(i = 1; i < n-1; i++){
        if(p[i-1] < p[i] && p[i + 1] > p[i]){
          count += 1;
        }else if(p[i-1] > p[i] && p[i + 1] < p[i]){
          count += 1;
        }
      }
      System.out.println(count);
	}
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,ll> iil;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	ll l,r;
	cin>>l>>r;
	if(r-l <= 2019)
	{
		ll min = INF;
		for(ll i=l;i<=r;i++)
		{
			for(ll j=i+1;j<=r;j++)
			{
				if((i*j)%2019 < min)min = (i*j)%2019;
			}
		}

		cout << min << "\n";
	}
	else
	{
		cout << "0\n";
	}
	return 0;
}

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

int dis2(int D, int x[10], int y[10]) {
  int sum=0;
  for(int i=0; i<D; ++i)
    sum += (x[i]-y[i])*(x[i]-y[i]);
  return sum;
}

bool issq(int a) {
  int b;
  b = (int)sqrt((double)a);
  if(b*b==a) return true;
  else return false;
}

int main() {
  int N, D, X[10][10];
  int count=0;
  cin >> N >> D;
  for(int i=0; i<N; ++i)
    for(int j=0; j<D; ++j)
      cin >> X[i][j];
  for(int i=0; i<N-1; ++i)
    for(int j=i+1; j<N; ++j)
      if(issq(dis2(D,X[i],X[j])))
        ++count;
  cout << count << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    cout << vec[N-1] - vec[0] << endl;
}


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

typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string a,b,c;
  int n,m;
  cin>>a>>b>>n>>m>>c;
  if(c==a)
  {
    cout<<n-1<<" "<<m<<endl;
  }
  else
  {
    cout<<n<<" "<<m-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;

    int ans = 0;
    int x = min(a,k);
    ans += x;
    a -= x;
    k -= x;

    if ( a == 0 )
    {
        x = min(b,k);
        b -= x;
        k -= x;

        if ( b == 0 )
        {
            x = min(c,k);
            ans += (-1)*x;
        }
    }

    cout<<ans<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	static final String[] KEYWORD = {"the", "that", "this"};
	
	public static void main(String[] args) throws Exception{
		//暗号を取得
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String cipher;
		while((cipher = br.readLine()) != null){
			//正しい複合化のための文字移動量を求める
			int movement = getMovement(cipher);
			//復号した分を出力
			System.out.println(decrypt(movement, cipher));
		}
	}
	
	public static String decrypt(int movement, String cipher){
		char[] c = cipher.toCharArray();
		for(int i = 0; i < c.length; i++){
			//a-z以外は複合しない
			if( c[i] < 'a' || 'z' < c[i] ){
				continue;
			}
			//復号
			c[i] = (char)(c[i] + movement);
			if(c[i] > 'z'){
				int fixMovement = c[i] - 'z';
				c[i] = (char)('a' - 1 + fixMovement);
			}
		}
		return String.valueOf(c);
	}
	private static int getMovement(String cipher){
		int movement = 0;
		for(int i = 1; i < 26; i++){
			if( decrypt(i, cipher).contains(KEYWORD[0]) ||
				decrypt(i, cipher).contains(KEYWORD[1]) ||
				decrypt(i, cipher).contains(KEYWORD[2]) ){
				movement = i;
				break;
			}
		}
		return movement;
	}
}

Measured memory_bytes: 17872
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int x, t; cin >> x >> t;
    if(x > t) cout << x - t << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.sort()
B.sort()
if N % 2 == 0:
    n = N // 2
    print(B[n] + B[n - 1] - A[n] - A[n - 1] + 1)
else:
    n = N // 2
    print((B[n] - A[n] + 1))

Measured memory_bytes: 25488
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define RG register
#define ll long long
using namespace std;
const int N=102;
struct node{
	int x,y; 
    ll h;
}pt[N];
int n;
inline ll abss(ll x)
{
    return x>0 ? x : -x;
}
inline ll read()
{
	char ch=getchar(); ll x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;}
inline bool cmp(node a,node b){return a.h>b.h;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		pt[i]=(node){read(),read(),read()};
	}
	sort(pt+1,pt+1+n,cmp);
	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			int flg=0;
			ll tt=abss(i-pt[1].x)+abss(j-pt[1].y)+pt[1].h;
			for(int k=2;k<=n;k++)
			{
				ll re=abss(i-pt[k].x)+abss(j-pt[k].y)+pt[k].h;
				if(pt[k].h==0)
				{
					if(tt>re-pt[k].h)
					{
						flg=1;
						break;
					}
					continue;
				}
				if(re!=tt)
				{
					flg=1;
					break;
				}
			}
			if(!flg) 
			{
				printf("%d %d %lld\n",i,j,tt);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define pll pair<ll,ll>

ll INF = 1000000007;


//-----------------//
  #define amin main
//-----------------//


int amin()
{
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,x,t;
	cin>>n>>x>>t;
	ll k = n/x;
	if(n%x==0)
	{
		cout<<k*t<<endl;
	}
	else
		cout<<(k+1)*t<<endl;
	
	
	


	
	return 0;
}

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

typedef long long ll;

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

    int n;cin>>n;
    vector<ll> a(n),b(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int j=0;j<n;j++) cin>>b[j];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    vector<int> v;
    for(int k=0;k<30;k++){
        // k-bit 目の答え
        ll t=(1<<k),cnt=0;
        vector<ll> btmp;
        for(int i=0;i<n;i++) btmp.push_back(b[i]%(1<<(k+1)));
        sort(btmp.begin(),btmp.end());
        for(int i=0;i<n;i++){
            ll atmp=a[i]%(1<<(k+1));
            auto st=lower_bound(btmp.begin(),btmp.end(),t-atmp);
            auto gt=lower_bound(btmp.begin(),btmp.end(),2*t-atmp);
            cnt += distance(st,gt);

            st=lower_bound(btmp.begin(),btmp.end(),3*t-atmp);
            gt=lower_bound(btmp.begin(),btmp.end(),4*t-atmp);
            cnt += distance(st,gt);
        }
        //cout<<k<<" "<<cnt<<endl;
        v.push_back(cnt%2);
    }
    ll res=0;
    for(int i=(int)v.size()-1;i>=0;i--){
        res *= 2;
        if(v[i]) res++;
    }
    cout<<res<<endl;
}


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

typedef long long ll;
const int maxn=110;

struct node
{
    int x,y;
}red[maxn],blue[maxn];

bool vis[maxn];

bool cmp1(node a,node b)
{
    if(a.y==b.y)
        return a.x>b.x;
    return a.y>b.y;
}

bool cmp2(node a,node b)
{
    if(a.x==b.x)
        return a.y<b.y;
    return a.x<b.x;
}

int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin >> red[i].x >> red[i].y;
    }
    for(int i=0;i<n;i++)
    {
        cin >> blue[i].x >> blue[i].y;
    }
    sort(red,red+n,cmp1);
    sort(blue,blue+n,cmp2);
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(vis[j])
                continue;
            if(red[i].x<blue[j].x&&red[i].y<blue[j].y)
            {
                cnt++;
                vis[j]=true;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
function main(input){
  const lines = input.split('\n')
  const N = parseInt(lines[0].split(' ')[0])
  const M = parseInt(lines[0].split(' ')[1])
  const Xs = lines[1].split(' ').map(x => parseInt(x))

  if(M<=N){console.log(0);return;};

  const target_section_count = M-N;
  const sorted_Xs = Xs.sort(function(a,b){return a-b;})
  var section_lengths = [];
  for(var i=0;i<M-1;i++){
    section_lengths.push(sorted_Xs[i+1] - sorted_Xs[i]);
  }

  const sorted_section_lengths = section_lengths.sort(function(a, b){return a-b;})

  var result = 0;
  for(var i=0;i<M-N;i++){
    result += sorted_section_lengths[i]
  }

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 28300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll mod = 1e9+7;


main(){
    int n,k;cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    ll dp[n+1][k+1];
    dp[0][0]=1;
    for(int i=1;i<=k;i++){
        dp[0][i]=0;
    }
    for(int i=1;i<=n;i++){
        vector<int> sum(k+1);
        sum[0] = dp[i-1][0];
        for(int j=1;j<=k;j++) sum[j] = (sum[j-1]+dp[i-1][j])%mod;
        for(int j=0;j<=k;j++){
           if(j<=a[i]) dp[i][j] = sum[j];
           else{
               int remove = j-a[i]-1;
               dp[i][j] = (sum[j]-sum[remove]+mod)%mod;
           }
        }
        sum.clear();
    }

    cout<<dp[n][k];
}

Measured memory_bytes: 82708
#include<bits/stdc++.h>
using namespace std;
const int N=1<<20;
int n;
multiset<int>s,s2;
multiset<int>::iterator it,it2;
int tot,st[N];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=1<<n;i++)
    {
        int x;scanf("%d",&x);s.insert(x);
    }
    it=s.end();
    it--;
    s2.insert(*it);
    s.erase(s.find(*it));
    while(s.size())
    {
        it2=s2.end();it2--;
        while(true)
        {
            it=s.lower_bound(*it2);
            if(it==s.begin()) {printf("No\n");return 0;}
            it--;st[++tot]=*it;s.erase(s.find(*it));
            if(it2==s2.begin()) break;
            it2--;
        }
        for(int i=1;i<=tot;i++) s2.insert(st[i]);tot=0;
    }
    printf("Yes\n");
}


Measured memory_bytes: 13056
#include <bits/stdc++.h>
#define ll long long
#define lll __int128_t
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdll pair<ld, pll >
#define ppp pair<pii, pii >
#define F first
#define S second
#define VI vector<int>
#define pb push_back
#define pp pop_back

const int P = 1000000007;

using namespace std;


int main(){

	VI x(5);
	for(int i=0; i<5; i++) cin >> x[i];
	int ans = 0;
	for(int i=0; i<5; i++) if(!x[i]) ans = i+1;
	cout << ans << '\n';

	return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

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

    K %= 50;
    rep(j, K) {
        int min_i = 0;
        rep(i, N) {
            if (a[min_i] > a[i]) min_i = i;
        }

        rep(i, N) if (i != min_i) a[i]--;
        a[min_i] += N;
    }

    cout << N << endl;
    rep(i, N) {
        cout << a[i];
        if (i != N - 1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
N = int(input())
A_list = list(map(int, input().split()))
mydic = { x:0 for x in range(N+1)}
#print(mydic)

for a in A_list:
    #print(a)
    mydic[a] += 1 
    
for d in range(1,N+1):
    print(mydic[d])

Measured memory_bytes: 38928
h,w,z = map(int, input().split())
ab = [input() for i in range(h)]


res = 0
ress = 0

import itertools
A =[0,1]
for i in itertools.product(A, repeat=h):
    for j in itertools.product(A, repeat=w):    
        res = 0
        for k in range(h):
            if i[k] ==1:
                for l in range(w):
                    if j[l] ==1 and ab[k][l]=="#":
                        res+=1
        if res ==z:
            ress+=1
print(ress)

Measured memory_bytes: 9204
N = int(input())

row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
grid = [row1, row2]

gridsum = grid.copy()

for i in (0, 1):
    for j in range(N):
        up = (i - 1, j)
        left = (i, j - 1)
        upsum = grid[up[0]][up[1]] if up[0] > -1 else 0
        leftsum = grid[left[0]][left[1]] if left[1] > -1 else 0

        gridsum[i][j] = max(upsum, leftsum) + gridsum[i][j]


print(gridsum[1][N - 1])

Measured memory_bytes: 3064
S = input()
N = len(S)
M = N//2
if N%2:
    for i in range(M):
        if S[M+i] != S[M+i+1]:
            print(M+i+1)
            exit()
        if S[M-i] != S[M-i-1]:
            print(M+i+1)
            exit()
    print(N)
else:
    if S[M] != S[M-1]:
        print(M)
        exit()
    for i in range(M-1):
        if S[M+i] != S[M+i+1]:
            print(M+i+1)
            exit()
        if S[M-i-1] != S[M-i-2]:
            print(M+i+1)
            exit()
    print(N)

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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < S.size(); i++) {
    if (i%2 == 0) {
      if (S.at(i) == 'L') {
        ans++;
      }
    }
    else
      if (S.at(i) == 'R') {
        ans++;
      }
  }
  if (ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

int main(){

    string S;
    cin >> S;

    int N = S.size();

    int sum=0;
    for(int i=0; i<N; i++){
        if(S[i] == '1')
            sum += 1;
    }

    int ans = min(N-sum,sum)*2;
        
    cout << ans << endl;
 }


Measured memory_bytes: 3744
#include<stdio.h>
#include<bitset>
int main()
{
	const int N=1000001;
	int i,j,n,c;
	std::bitset<N>p;
	p.set();
	for(i=2;i*2<N;++i)if(p[i])for(j=2*i;j<N;j+=i)p[j]=0;
	while(scanf("%d",&n),n)
	{
		for(c=0,i=j=n/2;i>1;--i,++j)if(p[i]&&p[j])c++;
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<vector<int>>input(n,vector<int>(3));

	rep(i,n) cin >> input[i][0] >> input[i][1] >> input[i][2];
	vector<vector<int>>dp(n,vector<int>(3));
	dp[0] = {input[0][0],input[0][1],input[0][2]};

	for(int i = 1; i<n;i++){
		rep(j,3){
			dp[i][0] = max(dp[i-1][1],dp[i-1][2])+input[i][0];
			dp[i][1] = max(dp[i-1][0],dp[i-1][2])+input[i][1];
			dp[i][2] = max(dp[i-1][0],dp[i-1][1])+input[i][2];			
		}
	}
	cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << endl;


	return 0;
}

Measured memory_bytes: 11136
from collections import deque

n, m = map(int, input().split())

g = [[] * 1 for i in range(n*3)]

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a * 3 + 0].append(b * 3 + 1)
    g[a * 3 + 1].append(b * 3 + 2)
    g[a * 3 + 2].append(b * 3 + 0)


s, t = map(int, input().split())
s -= 1
t -= 1
d = [-1 for i in range(n*3)]
q = deque([])
q.append(s*3+0)
d[s*3+0] = 0
while q:
    v = q.popleft()
    for to in g[v]:
        if d[to] == -1:
            d[to] = d[v] + 1
            q.append(to)

if d[t*3+0] == -1:
    print(-1)
else:
    print(d[t*3+0] // 3)


Measured memory_bytes: 60280
#include <iostream>

using namespace std;

int main(){
  int r,g,b,n;
 cin >> r >> g >> b >>n;
  int res=0;

  for(int i=0;i<=n/r;i++){
    for(int j=0;j<=(n-r*i)/g;j++){
   
      if((n-r*i-g*j)%b==0){
       res++;
      }
      
    }
  }

 cout << res <<endl;

}

Measured memory_bytes: 256
N = int(input())
C, S, F = zip(*(tuple(map(int, input().split())) for _ in range(N - 1)))
for i in range(N - 1):
    total = S[i] + C[i]
    for j in range(i + 1, N - 1):
        if total <= S[j]:
            total = S[j]
        else:
            div, rem = divmod(total, F[j])
            total = (div + bool(rem)) * F[j]
        total += C[j]
    print(total)
print(0)

Measured memory_bytes: 3188
#include<cstdio>
int main()
{
	int n,k,x,y;
	scanf("%d%d%d%d",&n,&k,&x,&y);
	if(n<=k)
	{
		printf("%d",n*x);
	}
	else
		printf("%d\n",k*x+(n-k)*y);
		return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    int wf[10][10];
    rep(i, 10) rep(j, 10) cin >> wf[i][j];

    rep(k, 10) rep(i, 10) rep(j, 10) wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

    ll ans = 0;
    rep(i, H){
        rep(j, W){
            int val; cin >> val;
            if(val != -1) ans += wf[val][1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<limits.h>
#define ll long long
using namespace std;
ll int min(ll int arr[],ll int p)
{
	ll int smallest=arr[0];
	for(ll int i=0;i<p;i++)
	{
		if(smallest>arr[i])
		  smallest=arr[i];
	}
	return smallest;
}
ll int function(ll int arr[],ll int initial,ll int final,ll int memo[],ll int k)
{
	if(memo[initial]!=-1)
	  return memo[initial];
	if(initial==final)
	  return 0;
	else
	{
		ll int array[100]={0};
	    ll int i;
	    ll int p=0;
		for(i=0;i<k;i++)
		{
			if(initial+i+1<=final)
			{
				array[p]=abs(arr[initial+i+1]-arr[initial])+function(arr,initial+i+1,final,memo,k);
				p++;
			}
			else
			  break;
		}
		memo[initial]=min(array,p);
		return memo[initial];
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll int n,k;
	cin>>n>>k;
	ll int arr[n];
	ll int j;
	ll int answer;
	for(j=0;j<n;j++)
	  cin>>arr[j];
	ll int memo[n];
	for(j=0;j<n;j++)
	  memo[j]=-1;
	answer=function(arr,0,n-1,memo,k);
	cout<<answer<<endl;
}


Measured memory_bytes: 90880
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long

const int inf = 1e9;

int a, b;

void run(int w, double ratio, int &l, int &r) {
  l = -1, r = -1;
  for(int i = 1; i <= 10000; i += 1) {
    int x = int(i * ratio);
    if(x == w) {
      if(l == -1) l = i;
      r = i;
    }
  }
}

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d%d", &a, &b);  
  int la, ra, lb, rb;
  run(a, 0.08, la, ra);
  run(b, 0.1, lb, rb);
  if(la <= rb && lb <= ra) {
    printf("%d\n", max(la, lb));
  }
  else {
    puts("-1");
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll ma=max({a,b,c});
	ll ma1=ma/2;
	ll ma2=ma-ma1;
	ll ans=1;
	if(ma==a){
		ans=b*c;
	}
	else if(ma==b){
		ans=a*c;
	}
	else{
		ans=a*b;
	}
	cout << (ma2-ma1)*ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;

int main() {
	
	string S,T;
	cin>>S>>T;
	
	int cnt=0;
	
	for(int i=0; i<S.size(); ++i) {
		if(S[i]!=T[i]) ++cnt;
	}
	
	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 3868
#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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<int> VI;
typedef vector<VI> VVI;

int main(){
    int n,m,res,count;
    long long l=0;
    cin >> n >> m;
    VI x(m);
    VI sub(m-1);
    REP(i,m){ cin >> x[i]; }
    if(m<=1){ cout << 0 << endl;} 
    else{
        sort(x.begin(), x.end());
        REP(i,m-1){ 
            sub[i] = x[i+1] - x[i]; 
        }
        sort(sub.begin(), sub.end());

        for(int i=0; i<m-n;i++){
            l += sub[i];
        }
        cout << l << endl;   
    }
    return 0;
}
   


Measured memory_bytes: 1024
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
	string str;
	cin >> str;

	if (str == "Sunny"){
      cout << "Cloudy" << endl;
    } else if (str == "Cloudy"){
      cout << "Rainy" << endl;
    } else {
      cout << "Sunny" << endl;
    }
  
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if ((  (N/1000 == N%1000/100) && (N%1000/100 == N%1000%100/10) &&(N%1000%100/10==N%1000%100%10) )||
  (  (N/1000 == N%1000/100) && (N%1000/100 == N%1000%100/10) &&(N%1000%100/10!=N%1000%100%10) )||
  (  (N%1000/100 == N%1000%100/10) &&(N%1000%100/10==N%1000%100%10)&& ( N%1000/100 !=  N/1000)  ) ){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{int a,b;
 cin>>a>>b;
 if((a+b)%3==0 || a%3==0 || b%3==0){
     cout<<"Possible"<<endl;
 }
 else{
     cout<<"Impossible"<<endl;
 }
 return 0;
}

Measured memory_bytes: 256
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 5e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];

void solve()
{
	int a, b;
	cin >> a >> b;
	string p, q;
	int t = a;
	while(t--)
	{
		p.push_back(b + '0');
	}
	t = b;
	while(t--)
	{
		q.push_back(a + '0');
	}
	cout << min(p, q) << endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

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

int main()
{
    char b;
    cin >> b;

    char ans = (b == 'A') ? 'T' : (b == 'T') ? 'A' : (b == 'C') ? 'G' : 'C';
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
# つよいさんすう
# 最初のAを単独で考えたらいける 等差数列の和の公式はググった
# ex) k = 3, a = [1, 3, 2]
# 1 3 2 1 3 2 1 3 2
# 最初の1 3 2
# 3...[2,1,2,1,2]で5
# 2...[1.1]で2
# 二番目の1 3 2
# 3...[2,1,2]
# 2...[1]
# 三番目の1 3 2
# 3...[2]で1

# 3だけでみると初項1 末項5 公差2で n(2*a1 +(n-1)*2)/2 = 3*(2*1 + (3-1)*2)/2 = 3*6/2 = 9
# n*(a1+an)/2 = 3*(1+5)/2 = 9
# これを一般化すればいけそう

# ex) k = 3, a = [3, 5, 2, 4, 1]とすると
# 3 5 2 4 1 3 5 2 4 1 3 5 2 4 1
# 3の初項は2で公差2 -> 3*(2*2+(3-1)*2)/2 = 12 (6+4+2)
# 5の初項は3で公差4 -> 3*(2*3 + (3-1)*4)/2 = 21 (11+7+3)
# 2の初項は1で公差2 -> 3*(2*1 + (3-1)*2)/2 = 9
# 4の初項は1で公差2 -> 3*(2*1 + (3-1)*3)/2 = 12
# 1の初項は0で公差0 -> 3*(2*0 + (3-1)*0)/2 = 0
# ...みたいな感じ

n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10**9 + 7
first_subarr = [0] * n
rest_arr = [0] * n
for i in range(n):
    for j in range(i, n):
        if a[i] > a[j]:
            first_subarr[i] += 1

for i in range(n - 1, -1, -1):
    for j in range(i, -1, -1):
        if a[j] < a[i]:
            rest_arr[i] += 1

diffs = [0] * n
for i in range(n):
    diffs[i] = first_subarr[i] + rest_arr[i]

ans = 0
for i in range(n):
    # print("{}について".format(a[i]))
    # print("初項:{} 公差:{}なので".format(first_subarr[i], diffs[i]))
    tmp = k * (2 * first_subarr[i] + (k - 1) * diffs[i]) // 2
    # print("総和は{}".format(tmp))
    ans += tmp
    ans %= MOD
print(ans)

Measured memory_bytes: 3188
def convert(n):
    r, i = "", 0
    while True:
        n, m = divmod(n, 26)
        if m == 0:
            n, m = n-1, 26
        r += chr(ord('`') + m)
        if n == 0:
            break
    return r[::-1]
print(convert(int(input())))

Measured memory_bytes: 80016