akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;
template<class T> T gcd( T a, T b ) {
    return !b ? a : gcd( b, a % b );
}
template<class T> T lcm( T a, T b ) {
    return a / gcd( a, b ) * b;
}
template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}



const string NOT_FOUND = "-1";
int n, k;

typedef II Edge;
typedef set <Edge> Edges;
typedef vector <Edges> SetEdges;

void solve() {
    if ( n / 2 < k ) {
        cout << NOT_FOUND << endl;
        return;
    }
    SetEdges se = SetEdges( k + 1 );
    se[0].insert( Edge( 1, 2 ) );
    int offset = 0;
    if ( n % 2 == 1 ) {
        se[0].insert( Edge( 2, 3 ) );
        offset = 1;
    }
    // for ( int N = 2; 2 * N <= n; ++ N ) {
    for ( int BN = 4 + offset; BN <= n; BN += 2 ) {
        for ( int i = 1; i <= min( BN / 2 - 1, k ); ++ i ) {
            // debug: 追加する枝の確認
            // cout << i << ": ";
            // cout << "test1: " << 2 * N - 1 << ", " << i << " / " << 2 * N << ", " << N + i - 1 << endl;
            se[i-1].insert( Edge( BN - 1, i ) );
            se[i-1].insert( Edge( BN, BN / 2 + i - 1 ) );
        }
        // debug: 
        // cout << "end" << endl;
        if ( BN / 2 > k ) continue;
        // debug: 追加する木と枝の確認
        // cout << N << ": " << endl;
        // cout << "test2: " << 2 * N - 1 << ", " << 2 * N << endl;
        se[BN/2-1].insert( Edge( BN - 1, BN ) );
        for ( int i = BN/2; i <= BN - 2; ++ i ) {
            // debug: 追加する枝の確認
            // cout << "test2: " << 2 * N - 1 << ", " << i << endl;
            // se[BN/2-1].insert( Edge( BN - 1, i ) );
        }
        for ( int i = 1; i <= BN / 2 - 1; ++ i ) {
            // debug: 追加する枝の確認
            // cout << "test2: " << 2 * N << ", " << i << endl;
            // se[BN/2-1].insert( Edge( BN, i ) );
        }
        for ( int i = 1; i <= BN / 2 - 1; ++ i ) {
            se[BN/2-1].insert( Edge( BN, i ) );
            se[BN/2-1].insert( Edge( BN - 1, BN / 2 + i - 1 ) );
        }
        if ( n % 2 == 1 ) se[BN/2-1].insert( Edge( BN - 2, BN - 1 ) );
    }
    for ( int i = 0; i < k; ++ i ) {
        // debug: 枝の数
        // cout << "test3: " << i << ": " << se[i].size() << endl;
    }
    for ( int i = 0; i < k; ++ i ) {
        for ( Edges::iterator it_i = se[i].begin(); it_i != se[i].end(); ++ it_i ) {
            printf( "%d %d\n", (*it_i).first, (*it_i).second );
        }
        if ( i + 1 < k ) putchar( '\n' );
    }
}

int main() {
    cin >> n >> k;
    solve();
    return 0;
}

Measured memory_bytes: 31000
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;++i)
#define M(a,b) make_pair(a,b)
#define f first
#define s second
using namespace std;
int dx[]={0,0,1,1,-1,-1,},dy[]={1,-1,1,0,-1,0};
bool v[200][200];
int a,b,t,n;
int main(){
  while(cin>>t>>n,t){
    r(i,200)r(j,200)v[i][j]=0;
    while(n--){
      scanf("%d%d",&b,&a);
      v[a+100][b+100]=1;
    }cin>>a>>b;int c=0;
    queue<pair<pair<int,int>,int> >q;
    q.push(M(M(b+100,a+100),0));
    v[b+100][a+100]=1;
    while(!q.empty()){
      pair<pair<int,int>,int > p=q.front();q.pop();
      if(p.s==t+2)continue;
      c++;
      r(i,6)if(!v[p.f.f+dy[i]][p.f.s+dx[i]]&&p.s+1<=t){
        q.push(M(M(p.f.f+dy[i],p.f.s+dx[i]),p.s+1));
        v[p.f.f+dy[i]][p.f.s+dx[i]]=1;
      }
    }
    cout<<c<<endl;
  }
}

Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {

  int N, M, Q;
  cin >> N >> M >> Q;
  int imos[N+1][N+1];

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j] = 0;
    }
  }

  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    imos[l][r]++;
  }

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      imos[i][j+1] += imos[i][j];
    }
  }

  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ans = 0;
    for (int j = l; j <= r; j++) {
      ans += imos[j][r];
    }
    cout << ans << endl;
  }

}


Measured memory_bytes: 1920
void main() {
    int r = readln.chomp.to!int;
    if (r < 1200) {
        "ABC".writeln;
    } else if (r < 2800) {
        "ARC".writeln;
    } else {
        "AGC".writeln;
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};

using namespace std;

int main(){
    int x,a,b;
cin>>x>>a>>b;
  if(abs(x-a)>abs(x-b))
          cout<<"B";
  else
    cout<<"A";
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  
  for(int i=0; i < N; i++){
    cin >> a.at(i);
  }
  
    vector<int> b(N + 1);
  
  for(int i = 0; i < N; i++){
  	b.at(a.at(i)) = i + 1;
  }
  
  for(int i = 1; i < N + 1; i++){
  	cout << b.at(i) << " ";
  }
  cout << endl;
}


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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    vector<int> prices(3);
    prices[0] = A * X + B * Y;
    prices[1] = max(2 * C * min(X,Y) + A * (X - Y),  2 * C * min(X,Y) + B * (Y - X));
    prices[2] = max(X, Y) * 2 * C;
    cout << *min_element(prices.begin(), prices.end());
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e18;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;


void solve()
{
    
    int a[6];
    for(int i=1;i<=5;i++)
    {
        cin>>a[i];
        if(!a[i])
        {
            cout<<i<<endl;
            return;
        }
    }
    
    
}



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


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF =(1LL<<31);

typedef pair<ll,ll> Pii;
typedef pair<ll,string> Pis;
typedef pair< Pii , Pis > PP;

ll N,M,K;
ll G[32][32];
ll g[32][32];

set< PP > u[32][32];

ll mem[32][32];

ll search(ll from,ll to){
  if(mem[from][to]!=-1)return mem[from][to];
  ll mini=INF, res=-1;
  for(int i=0;i<N;i++){
    if(from==i || g[from][i]==INF)continue;
    if(mini>g[from][i]+G[i][to]){
      mini=g[from][i]+G[i][to];
      res=i;
    }
  }
  assert(res!=-1);
  return mem[from][to]=res;
}

void init(){
  for(int i=0;i<32;i++){
    for(int j=0;j<32;j++){
      g[i][j]=(i==j?0:INF);
      G[i][j]=(i==j?0:INF);
      mem[i][j]=-1;
      u[i][j].clear();
    }
  }
}

int main(){
  ll cnt=0;
  while(1){

    init();
    cin>>N>>M;
    if(N==0&&M==0)break;
    if(cnt)cout<<endl;
    cnt++;
    
    for(int i=0;i<M;i++){
      ll a,b,c;
      cin>>a>>b>>c;
      a--,b--;
      G[a][b]=G[b][a]=c;
    }
    
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++)
        g[i][j]=G[i][j];
    
    for(int k=0;k<N;k++)
      for(int i=0;i<N;i++)
        for(int j=0;j<N;j++)
          G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
    
    cin>>K;

    map<ll, vector<PP> > mp;
    set<ll> st;
    
    for(int i=0;i<K;i++){
      ll from,to,ti;
      string name;
      cin>>from>>to>>ti>>name;
      from--,to--;
      mp[ti].push_back( PP( Pii(from,to) , Pis(0,name)) );
      st.insert(ti);
    }

    vector< Pis > ans;
    vector<ll> v(N,0);
    ll last=-1;
    
    st.insert(0);
    while(!st.empty()){

      ll p=*st.begin();
      assert( last < p ); last=p;
      
      if(mp.count(p)){
        for(int i=0;i<(int)mp[p].size();i++){
          PP pp=mp[p][i];
          ll from=pp.first.first;
          ll to=pp.first.second;
          string name=pp.second.second;
          ll key=search(from,to);
          PP tmp=PP( Pii(p, key ) , Pis(to,name) );
          u[from][key].insert(tmp);
        }
        //       mp[p].clear();
      }
      
      for(int i=0;i<N;i++){
        if(v[i]>p)continue;
        
        PP target=PP( Pii(INF,0) , Pis(0,"") );
        
        for(int j=0;j<N;j++){
          if(u[i][j].empty())continue;
          PP pp=*u[i][j].begin();
          target=min(target,pp);
        }
        if(target.first.first==INF)continue;

        ll nex=target.first.second;
        
        set< PP > :: iterator it;
        for( it=u[i][nex].begin(); it!= u[i][nex].end() ; it++ ){
          PP pp=*it;
          ll to=pp.second.first;
          string name=pp.second.second;

          if(to==nex){
            ans.push_back( Pis( p+g[i][nex] , name ) );
          }else{
            mp[ p+g[i][nex] ].push_back( PP(Pii(nex,to),Pis(0,name)) );
          }
        }// iterator
        
        u[i][nex].clear();
        v[i]=p+g[i][nex]*2;
        st.insert(p+g[i][nex]);
        st.insert(p+g[i][nex]*2);
      }// i
      
      st.erase(p);
    }// while ( st.empty() )
    
    sort(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();i++){
      Pis p=ans[i];
      cout<<p.second<<' '<<p.first<<endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3508
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
import sys

INF = 1145141919


def solve(S: int, W: int):
    return 'unsafe' if W >= S else 'safe'


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    print(solve(S, W))


if __name__ == '__main__':
    main()


Measured memory_bytes: 61904
// 2020-09-20 23:35:13
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
#include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
using namespace atcoder;
using T = tuple<int, int, int>;

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<T> p(n);
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    p[i] = T(x, y, i);
  }
  sort(RALL(p));
  dsu d(n);
  set<P> s;
  for (auto [x, y, i] : p) {
    auto itr = s.lower_bound(P(y, -1));
    while (itr != s.end()) {
      auto [by, bi] = *itr;
      if (y < by) d.merge(i, bi);
      itr++;
    }
    if (d.size(i) == 1) s.emplace(P(y, i));
  }
  rep(i, n) cout << d.size(i) << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ll long long

static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;



// 深さ優先探索
vector<bool> seen;
vector<int> colors;


typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
// 入力
int H, W;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
queue<pair<int, int>> que;


int main() {

    ll N; cin >> N;
    vector<ll> A(N);
    map<ll, ll> sum;
    ll ans = 0;
    REP(i, N){
        cin >> A[i];
        sum[A[i]]++;
        ans += A[i];
    }
    ll Q; cin >> Q;
    vector<ll> ans_;
    REP(i, Q){
        ll b, c;
        cin >> b >> c;
        ans += sum[b]  * (c-b);
        ans_.push_back(ans);
        if(sum[c]==0)sum[c] = sum[b];
        else sum[c] += sum[b];
        sum[b] = 0;
    }

    REP(i, ans_.size()){
        cout << ans_[i] << endl;
    }

}

/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

int main() {
    long long int N, X, sum = 0;
    int rem;
    cin>>N;
    X = N;
    while (X != 0)
    {
        rem = X % 10;
        sum += rem;
        X = X / 10;
    }
    if (N % sum == 0)
        cout<<"Yes";
    else
        cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>                                                      
 
int main()
{
    int h, w; 
    while(scanf("%d%d", &h, &w) != EOF && h+w)
    {
        for (int i = 0; i < h; i++)
        {
            if (i&0x1)
            {
                for (int j = 0; j < w; j++)
                {
                    if (j&0x1)
                        printf("#");
                    else
                        printf(".");
                }
            }
            else 
            {
                for (int j = 0; j < w; j++)
                {
                    if (j&0x1)
                        printf(".");
                    else
                        printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2608
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int n;
	double x;
	cin>>n;
	if(n%2==1) x=(n+1)/2.0/n;
	else x=n/2.0/n;
	cout<<fixed<<setprecision(10)<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

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

    bool exists[128] = {};

    for (char c = 'a'; c <= 'z'; c++) {
        auto iter = find(S.begin(), S.end(), c);
        if (iter == S.end()) continue;

        const char cc = T[iter - S.begin()];
        if (exists[cc]) {
            cout << "No" << endl;
            return 0;
        } 
        exists[cc] = true;

        int count = 0;
        for (; iter != S.end(); iter = find(++iter, S.end(), c)) {
            if (T[iter - S.begin()] != cc) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios::sync_with_stdio(false);

    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> score(n, k);
    vector<ll> good(n, 0);
    for (ll i = 0; i < q; i++) {
        ll x;
        cin >> x;
        good[x - 1]++;
    }
    for (ll i = 0; i < n; i++) {
        cout << (k - (q - good[i]) > 0 ? "Yes\n" : "No\n");
    }

    return 0;
}

Measured memory_bytes: 2176
// 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    int amax = -1;
    for (int i = 0; i < T; ++i) 
    {
        cin >> a[i];
        amax = std::max(amax, a[i]);
    }
    int ans = std::max(amax - 1 - (K - amax), 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
X, N = map(int, input().split())
if N !=0:
  A = list(map(int, input().split()))
  A.sort()
MIN = 1000
if N ==0:
  print(X)
elif not X in A:
  print(X)
else:
  for i in range(X*10):
    N = abs(X - i)
    if not i in A:
      if MIN > N:
        Z = i
        MIN = N
  print(Z)	

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = (h2 * 60 + m2) - (h1 * 60 + m1) - k;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
def gcd(a,b):
    if(b==0):
        return a
    return gcd(b,a%b)
import math
a,b = map(int,input().split())
x = gcd(a,b)
c= x
ans = 1
for i in range(2,int(math.sqrt(x))+1):
    if(c%i==0):
        ans+=1
    while(c%i==0):
        c=c//i
        
if(c>1):
    ans+=1
print(ans)

Measured memory_bytes: 3064
n,m = map(int,input().split())
L = list(map(int,input().split()))
dp = [float('inf')]*50001
for i in range(len(L)):
    dp[L[i]] = 1
for i in range(2,50001):
    for j in range(len(L)):
        if i-L[j] >= 1:
            dp[i] = min(dp[i-L[j]]+1,dp[i])
print(dp[n])


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

int main()
{
    int n, i, j, k = 0;
    cin>>n;
    int s[n];
    for(i=0; i<n; i++)
        scanf("%d", &s[i]);

    sort(s, s+n);

    for(i = n-1; i >= 0; i--){
        k+=s[i];
    }

    if (k % 10 != 0) {
        cout << k << endl;
    } else {
    sort(s, s+n);
    for(i = 0; i < n; ++i) {
      if (s[i] % 10 != 0) {
        cout << k - s[i] << endl;
        return 0;
      }
    }
    cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int n, q;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    unordered_map<int, int> m;
    for(int i = 0; i<n; i++){
        cin >> a[i];
        s+=a[i];
        m[a[i]]++;
    }
    cin >> q;
    // sort(a.begin(), a.end());

    for(int i = 0; i<q; i++){
        int b, c;
        cin >> b >> c;
        int count = m[b];
        m[b] = 0;
        m[c]+=count;
        int neg = count * b;
        int pos = count * c;
        s = s - neg + pos;
        cout << s <<"\n";
    }
    return 0;
}


Measured memory_bytes: 7828
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

static const int N = 4;
static const int N2 = 16;
static const int LIMIT = 100;
int MDT[N2][N2];

struct Puzzle { int f[N2], space, MD; };

Puzzle state;
int limit;
int path[LIMIT];

int getAllMD(Puzzle pz) {
    int sum = 0;
    for (int i = 0; i < N2; i++) {
        if (pz.f[i] == N2) continue;
        sum += MDT[i][pz.f[i] - 1];
    }
    return sum;
}

static const int dx[] = {0, -1, 0, 1};
static const int dy[] = {1, 0, -1, 0};
static const char dir[] = {'r', 'u', 'l', 'd'};

bool dfs(int depth, int prev) {
    if (state.MD == 0) return true;
    if (depth + state.MD > limit) return false;

    int sx = state.space / N;
    int sy = state.space % N;
    Puzzle tmp;

    for (int r = 0; r < 4; r++) {
        int tx = sx + dx[r];
        int ty = sy + dy[r];
        if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
        if (max(prev, r) - min(prev, r) == 2) continue;
        tmp = state;

        state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
        state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
        swap(state.f[tx * N + ty], state.f[sx * N + sy]);
        state.space = tx * N + ty;
        if (dfs(depth + 1, r)) { path[depth] = r; return true;}
        state = tmp;
    }
    return false;
}

string iterative_deepening(Puzzle in) {
    in.MD = getAllMD(in);

    for (limit = in.MD; limit <= LIMIT; limit++) {
        state = in;
        if (dfs(0, -100)) {
            string ans = "";
            for (int i = 0; i < limit; i++) ans += dir[path[i]];
            return ans;
        }
    }
    return "unsolvable";
}


int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    for (int i = 0; i < N2; i++) {
        for (int j = 0; j < N2; j++) {
            MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
        }
    }
    Puzzle in;
    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            in.f[i] = N2;
            in.space = i;
        }
    }
    string ans = iterative_deepening(in);
    cout << ans.size() << endl;
    return 0;
}

Measured memory_bytes: 3176
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        sc.close();
        if (X == 7 || X == 5 || X == 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define LL long long
#define lson rt<<1
#define rson rt<<1|1
#define LS lson,l,mid
#define RS rson,mid+1,r
using namespace std;
const int maxn = 2e5+10;
int tree[maxn<<2];
LL add[maxn<<2];
int a[maxn], tot, ty[maxn], b[maxn] ,c[maxn];
void upd(int rt,int l,int r,int pos, LL t){
    if (l == r){
        tree[rt]++;
        add[rt] += t;
        return;
    }
    int mid = (l+r) >> 1;
    if (pos <= mid) upd(LS,pos,t);
    if (mid <  pos) upd(RS,pos,t);
    tree[rt] = tree[lson] + tree[rson];
    add[rt] = add[lson] + add[rson];
}
void query(int rt,int l,int r,int rest, int &pos){
    if (l == r){
        pos = l;
        return;
    }
    int mid = (l + r) >>1;
    if (tree[lson] >= rest) query(LS, rest, pos);
    else{
        rest -= tree[lson];
        query(RS, rest, pos);
    }
}
LL qs(int rt,int l,int r,int L,int R){
    if (L <= l && r <= R) return add[rt];
    int mid = (l + r) >> 1;
    LL ans = 0 ;
    if (L <= mid) ans += qs(LS, L, R);
    if (mid < R)  ans += qs(RS, L, R);
    return ans;
}
int qn(int rt,int l,int r,int L,int R){
    if (L <= l && r <= R) return tree[rt];
    int mid = (l + r) >> 1;
    int ans = 0 ;
    if (L <= mid) ans += qn(LS, L, R);
    if (mid < R)  ans += qn(RS, L, R);
    return ans;
}
int main(){
    int Q;
    scanf("%d",&Q);
    tot = 0;
    for (int i=1;i<=Q;i++){
        scanf("%d",&ty[i]);
        if (ty[i] == 1) {
            scanf("%d%d",&a[i],&b[i]);
            c[tot++] = a[i];
        }
    }
    sort(c,c+tot);
    int tt = 1;
    for (int i=1;i<tot;i++) if (c[i] != c[i-1]) c[tt++] = c[i];
    tot = tt;

    LL sum = 0; int now = 0;
    for (int i=1;i<=Q;i++){
        if (ty[i] == 1){
            now++;
            int aa = a[i];
            aa = lower_bound(c, c + tot, aa) - c + 1;
            sum += b[i];
            upd(1, 1, tot, aa, a[i]);

        }else{
            int pos = -1;
            query(1, 1, tot, (now+1)/2, pos);
            LL cntl = qs(1, 1, tot, 1, pos);
            int cl = qn(1, 1, tot, 1, pos);
            LL cntr = pos + 1 > tot ? 0 : qs(1, 1, tot, min(tot, pos+1), tot);
            int cr = pos + 1 > tot ? 0 : qn(1, 1, tot, min(tot, pos+1), tot);

            LL ans = cntr + 1LL * (cl - cr) * c[pos-1] - cntl;
            cout<<c[pos - 1]<<" "<<ans + sum<<endl;
        }
    }
    return 0;
}


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

const int INF = 1e9;

int main() {
  int n,m;
  cin>>n>>m;
  int a[10];
  for(int i=0;i<10;i++)a[i]=0;
  for(int i=0;i<m;i++){
    int ai;
    cin>>ai;
    a[ai]=1;
  }

  map<int, string> digits;
  if(a[1]==1) digits.emplace(2, to_string(1));

  if(a[5]==1){
    digits.emplace(5, to_string(5));
  }else if(a[3]==1){
    digits.emplace(5, to_string(3));
  }else if(a[2]==1){
    digits.emplace(5, to_string(2));
  }

  if(a[4]==1){
    digits.emplace(4, to_string(4));
  }

  if(a[9]==1){
    digits.emplace(6, to_string(9));
  }else if(a[6]==1){
    digits.emplace(6, to_string(6));
  }

  if(a[7]==1){
    digits.emplace(3, to_string(7));
  }

  if(a[8]==1){
    digits.emplace(7, to_string(8));
  }

  string dp[n+1];
  for(int i=0;i<n+1;i++){
    dp[i]="";
  }
  for(auto d: digits){
    if(d.first<n+1){
      dp[d.first]=d.second;
    }
  }
  for(int i=2;i<n+1;i++){
    string max_s="";
    for(auto d: digits){
      if(i-d.first<0){
        continue;
      }
      if(dp[i-d.first]==""){
        continue;
      }
      string tmp=d.second+dp[i-d.first];
      if(tmp.length()>max_s.length()){
        max_s=tmp;
      }else if(tmp.length()==max_s.length()){
        if(tmp>max_s){
          max_s=tmp;
        }
      }
    }
    if(max_s.length()>dp[i].length()){
      dp[i]=max_s;
    }else if(max_s.length()==dp[i].length()){
      if(max_s>dp[i]){
        dp[i]=max_s;
      }
    }
  }
  cout<<dp[n]<<endl;
}

Measured memory_bytes: 32384
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

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

    vector<int> d(N);

    REP(i, N)
    {
        cin >> d.at(i);
    }

    sort(d.begin(), d.end());

    cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
}


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

using namespace std;

const int MAXN=1e5+7;
const int mod=1e9+7;

int num[MAXN];


int main(){
    ios::sync_with_stdio(false);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a*n,b);

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define repr(i, a, n) for (ll i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int x;
  int max = 1;
  int tmp;
  cin >> x;
  rep(i, 2, sqrt(x)) {
    tmp = i * i;
    while (tmp <= x) {
      if (tmp > max)
        max = tmp;
      tmp *= i;
    }
  }
  cout << max << endl;
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // CとC++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, double> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;


int main() {
	int N, S;
	cin >> N >> S;
	vi a(N);
	rep(i, N) {
		cin >> a[i];
	}
	vll sum(N + 1);
	sum[0] = 0;
	repl(i, 1, N + 1) {
		sum[i] = sum[i - 1] + a[i - 1];
	}
	int ans = INF;
	int l = 0, r = 1;
	while (r < N + 1) {
		while (r < N && sum[r] - sum[l] < S)r++;
		while (l < r && sum[r] - sum[l] >= S)l++;
		//cout << l << " " << r << endl;
		l--;
		if(r < N + 1 && l < r && sum[r] - sum[l] >= S)ans = min(ans, r - l);
		l++;
		r++;
	}
	if (ans == INF) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

string f(int n, int L){
    string ret;
    rep(_, L-to_string(n).size()) ret += "0";
    ret += to_string(n);
    return ret;
}

int main(){
    string s;
    int L;
    while(cin >> s >> L && L){
        map<int, int> mp;
        s = f(stoi(s), L);
        for(int i=0;;++i){
            if(mp.find(stoi(s)) != mp.end()){
                int j = mp[stoi(s)];
                cout << j << " " << stoi(s) << " " << i-j << "\n";
                break;
            }
            mp[stoi(s)] = i;
            string t = s;
            sort(s.begin(), s.end());
            sort(t.begin(), t.end(), greater<>());
            s = f(stoi(t) - stoi(s), L);
        }
    }
}


Measured memory_bytes: 3292
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
ans=0
for i in range(n):
  if i>=k and t[i]==t[i-k]:
    t[i]=' '
  if t[i]=="r":
    ans+=p
  elif t[i]=="s":
    ans+=r
  elif t[i]=="p":
    ans+=s
print(ans)

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

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, k; cin >> n >> k;
	if (k % 2) {
		cout << 1LL*(n/k)*(n/k)*(n/k) << '\n';
	} else {
		cout << 1LL*(n/k)*(n/k)*(n/k) + 1LL*((n + k/2)/k)*((n + k/2)/k)*((n + k/2)/k) << '\n';
	}

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,T = inpl()
aa = inpl()
MAX = max(aa)

if MAX <= (K+1)//2:
	print(0)
else:
	zan = MAX - (K+1)//2
	if K%2 == 0:
		print(zan*2-1)
	else:
		print(zan*2)


Measured memory_bytes: 4468
#include <cstdio>
#include <cctype>
#include <vector>
#define rr register
using namespace std;
const int mod=1000000007,N=301;
struct rec{int l,x;};
int dp[N][N][N],n,m,ans; vector<rec>K[N];
inline signed iut(){
	rr int ans=0; rr char c=getchar();
	while (!isdigit(c)) c=getchar();
	while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans;
}
inline void Mo(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
inline signed check(int i,int j,int k){
	for (rr int p=0;p<K[i].size();++p){
		rr int l=K[i][p].l,x=K[i][p].x;
		if (x!=(i>=l)+(j>=l)+(k>=l)) return dp[i][j][k]=0;
	}
	return dp[i][j][k];
} 
signed main(){
	n=iut(),m=iut(),dp[1][0][0]=3;
	for (rr int i=1;i<=m;++i){
		rr int l=iut(),r=iut(),x=iut();
		K[r].push_back((rec){l,x});
	}
	for (rr int i=1;i<n;++i) for (rr int j=0;j<i;++j)
	    for (rr int k=0,t;k<j+(!k);++k) if (t=check(i,j,k))
		    Mo(dp[i+1][j][k],t),Mo(dp[i+1][i][j],t),Mo(dp[i+1][i][k],t);
	for (rr int j=0,t;j<n;++j)
	for (rr int k=0;k<j+(!k);++k)
	    if (t=check(n,j,k)) Mo(ans,t);
	return !printf("%d\n",ans);
}

Measured memory_bytes: 57168
object Main extends App {
  case class Status(x: Double = 0.0, y: Double = 0.0, angle: Double = Math.PI/2)
  def loop(status: Status): Status = {
    val arr = readLine().trim().split(',')
    val (a, b) = (arr(0).toInt, arr(1).toInt)
    if (a == 0 && b == 0) {
      println(status.x.toInt)
      println(status.y.toInt)
      status
    }
    else {
      loop(new Status(status.x + a*Math.cos(status.angle), status.y + a*Math.sin(status.angle), status.angle - Math.PI*b/180.0))
    }
  }
  loop(new Status)
}

Measured memory_bytes: 43812
[A, B, C] = [int(i) for i in input().split()]
K = int(input())

for i in range(K+1):
  _B = B * (2 ** i)
  if A < _B:
    for j in range(K+1-i):
      _C = C * (2 ** j)
      if _B < _C:
        print('Yes')
        break
    else:
      continue
    break
else:
  print('No')

Measured memory_bytes: 9196
#include<stdio.h>
int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1 && b!=1)
		printf("Alice\n");
	else if(b==1 && a!=1)
		printf("Bob\n");
	else if(a>b)
		printf("Alice\n");
	else if(a<b)
		printf("Bob\n");
	else if(a==b)
		printf("Draw\n");
	return 0;
}

Measured memory_bytes: 128
// exp worth blood
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
using namespace std;
const ll base = 7;
const ll maxn = 2e5 + 9;
const ll inf = 1e6;
typedef pair<ll,ll> LL;
vector<ll> g1[maxn],g2[maxn];
ll cnt1,cnt2;
ll n,k,l,i,j;
ll x,y,res[maxn],col1[maxn],col2[maxn];
bool vis1[maxn],vis2[maxn];
map<ll,ll> mkp;
void dfs1(ll now){
    col1[now] = cnt1;
    vis1[now] = true;
    for (auto i : g1[now]) if (!vis1[i]) dfs1(i);
}
void dfs2(ll now){
    col2[now] = cnt2;
    vis2[now] = true;
    for (auto i : g2[now]) if (!vis2[i]) dfs2(i);
}

int main(){
    ios_base::sync_with_stdio(false);
   	cin.tie(0); cout.tie(0);
    //freopen("test.inp", "r", stdin);
    cin>>n>>k>>l;
    while(k--){
       cin>>x>>y;
       g1[x].pb(y);
       g1[y].pb(x);
    }
    while(l--){
       cin>>x>>y;
       g2[x].pb(y);
       g2[y].pb(x);
    }

    for (i=1;i<=n;i++){
        if (!vis1[i]){
            dfs1(i);
            cnt1++;
        }
        if (!vis2[i]){
            dfs2(i);
            cnt2++;
        }
    }
    for (i=1;i<=n;i++) mkp[col1[i]*inf + col2[i]]++;
    for (i=1;i<=n;i++) cout<<mkp[col1[i]*inf + col2[i]]<<" ";
}


Measured memory_bytes: 32384
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll k;
int main(){FAST;
cin>>k;
ll sum = 0;
for(ll i=1;i<=k;++i){
  for(ll j=1;j<=k;++j){
    for(ll f=1;f<=k;++f){
      sum+=__gcd(__gcd(i,j),f);
    }
  }
}
cout<<sum;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


Measured memory_bytes: 3652
#include <stdio.h>
#include <math.h>
int main(){
  int a,b;
  double C;
  scanf("%d %d %lf",&a,&b,&C);
  C=M_PI/180*C;
  printf("%lf\n",0.5*a*b*sin(C));
  printf("%lf\n",a+b+sqrt(a*a+b*b-2*a*b*cos(C)));
  printf("%lf\n",b*sin(C));
  return 0;
}


Measured memory_bytes: 2004
#include <bits/stdc++.h>
#define ll long long
#define pb push_back 
#define mp make_pair
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
string p1, p2;
int calc(int l, int r){
	int result = 0;
	for (int i = l ; i <= r ; i++){
		if (p1[i] != p2[i - l]) result++;
	}
	return result;
}
int main() { fastIO
	cin >> p1 >> p2;
	int n = p1.size(),  l = 0, r = p2.size() - 1;
	int dif = 10000;
	while (r < n){
		dif = min(dif, calc(l, r));
		l++; r++;
	}	cout << dif << endl;
    return 0;
}



Measured memory_bytes: 3632
open Printf
open Scanf

let id x = x

let read_array n =
  Array.init n (fun i -> if i = n-1 then scanf "%d\n" id else scanf "%d " id)

let print_array a n bi =
  Array.iteri (fun i x -> if i = n-1 then begin
                              if i = bi then printf "[%d]\n" x
                              else printf "%d\n" x
                            end             
                          else begin
                              if i = bi then printf "[%d] " x
                              else printf "%d " x
                            end
              ) a

let partition a p r =
  let swap i j =
    let t = a.(i) in
    a.(i) <- a.(j);
    a.(j) <- t in
  let x = a.(r) in
  let rec iter i j =
    if j = r then begin swap (i+1) r; i+1 end
    else if a.(j) <= x then
      let ii = i+1 in
      swap ii j;
      iter ii (j+1)
    else iter i (j+1) in
  iter (p-1) p
  
let () =
  let n = scanf "%d\n" id in
  let ar = read_array n in
  let i = partition ar 0 (n-1) in
  print_array ar n i

Measured memory_bytes: 5384
package main

import (
	"fmt"
	"strconv"
)

var n = [4]int{}

func main() {
	fmt.Scanf("%1d%1d%1d%1d", &n[0], &n[1], &n[2], &n[3])
	fmt.Println(dfs(0, 0, "") + "=7")
}

func dfs(c, v int, s string) string {
	if c == 4 {
		if v == 7 {
			return s[1:]
		}
		return ""
	}

	a := dfs(c+1, v+n[c], s+"+"+strconv.Itoa(n[c]))
	b := dfs(c+1, v-n[c], s+"-"+strconv.Itoa(n[c]))
	if a != "" {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)

int INF = 2147483647;
struct RUQ{//平方分割 0-index
	int n,rn,bn,Q=0;
	vector<P> a,b;
	RUQ(int n_){
		n = n_; rn = sqrt(n); bn = ceil((double)n/rn);
		a.resize(n,{2147483647,0});
		b.resize(bn,{2147483647,0});
	}
	int value(int s){
		if(a[s].second < b[s/rn].second){
			a[s] = b[s/rn];
		}
		return a[s].first;
	}
	void updete(int s,int t,int x){
		Q++;
		FOR(i,s,t+1){
			if(i%rn==0 && (i+rn-1)<=t){
				b[i/rn] = {x,Q};
				i += rn-1;
			}else{
				a[i] = {x,Q};
			}
		}
	}
};

int main(){
	int N,Q;
	cin >> N >> Q;
	priority_queue<pair<int,P>> pq;
	vector<int> D(Q+1,INF);
	FOR(i,0,N){
		int s,t,x;
		cin >> s >> t >> x;
		pq.push({x,{s-x,t-x}});
	}
	FOR(i,0,Q){
		cin >> D[i];
	}
	RUQ ruq(Q+1);
	FOR(i,0,N){
		int s = pq.top().second.first;
		int t = pq.top().second.second;
		int x = pq.top().first;
		pq.pop();
		s = (lower_bound(D.begin(),D.end(),s)-D.begin());
		t = (lower_bound(D.begin(),D.end(),t)-D.begin());
		ruq.updete(s,t-1,x);
	}
	FOR(i,0,Q){
		int ans = ruq.value(i);
		if(ans==INF) ans = -1;
		cout << ans << endl;
	}
}


Measured memory_bytes: 7280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll N,ans=1,a,b;
	cin >> N;
	priority_queue<P> Q;
	FOR(i,0,N)cin>>a,Q.push({-a,-1});
	FOR(i,0,N)cin>>a,Q.push({-a,1});
	while(!Q.empty()){
		a = b = 0;
		while(not(a==0 && b!=0)){
			if(a != Q.top().second*llabs(a))(ans *= llabs(a) )%=MOD;
			a+=Q.top().second;
			Q.pop();
			b++;
		}
	}
	cout << ans << endl;
}

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

int main(void){
    ll n, k, ans = 0;
    cin >> n >> k;
    vector<ll> a(n); vector<vector<ll>> b(n, vector<ll>(n, 0));
    queue<pair<int, int>> cur, nxt;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int l = 0; l < n; l++) for (int r = l; r < n; r++){
        b[l][r] = b[l][max(0, r - 1)] + a[r];
        cur.push({l, r});
    }

    auto count = [&](ll bit, bool update) -> ll{
        ll cnt = 0, l, r, ok;
        while (!cur.empty()){
            tie(l, r) = cur.front(); cur.pop();
            ok = (bit & b[l][r]);
            if (ok) cnt++;
            if (!update || ok) nxt.push({l, r});
        }
        swap(cur, nxt);
        return cnt;
    };

    for (int nd = 40; nd >= 0; nd--){
        ll bit = 1LL << nd;
        if (count(bit, false) >= k) {
            count(bit, true);
            ans += bit;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15608
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin.shift());
    const A = stdin.shift().split(' ').map(Number);

    const a = partition(A, 0, n);
    console.log(a.join(' '));
}

function partition(A, left, right) {
    let x = A[right - 1];
    let lower = left;
    for (let i = left, l = right - 1; i < l; i++) {
        if (A[i] <= x) {
            let t = A[i];
            A[i] = A[lower];
            A[lower] =t;
            lower++;
        }
    }
    t = A[lower];
    A[right - 1] = t;
    x = `[${x}]` ;
    A[lower] = x;
    return A;
}

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



Measured memory_bytes: 31492
#include <stdio.h>

int main(void)
{
	int a, b;
	a = 1;
	b = 1;
	
	while (a < 10) {
		while (b < 10) {
			printf("%dx%d=%d\n", a, b, a * b);
			++b;
		}
		++a;
		b = 1;
	}

	return 0;
}



Measured memory_bytes: 2520
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1000000000


int main()
{
    int n,m,cnt=0;
    cin>>n>>m;
    vector<int>v;
    int id=2;
    for(int i=1;i<=n;i++)
    {
        v.push_back(id);
        //cout<<id<<endl;
        id+=2;
    }
    //cout<<"id"<<endl;
    id=1;
    for(int i=1;i<=m;i++)
    {
        v.push_back(id);
        id+=2;
    }
    sort(v.begin(),v.end());
    //cout<<"Ok"<<endl;
    for(int i=0;i<v.size();i++)
    {
        for(int j=i+1;j<v.size();j++)
        {
            if((v[i]+v[j])%2==0) cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0;i<(int)(n);i++)
using P = pair<int,int>;
// i<j
// j-i=v[i]+v[j]
// j-v[j]=v[i]+i
signed main() {
    int n;cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    map<int,int> mp;
    int ans = 0;
    rep(i, n) {
        ans+=mp[i+1-v[i]];
        mp[i+1+v[i]]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27444
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
#include<math.h>
using namespace std;
#define ll long long
int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   cout << c+b-d <<" " << d+c-a<<" " << a+b-d<<" "<< b+c-a<<endl;
}


Measured memory_bytes: 256