akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>


int dp[2][3];


int main()
{
    std::ios::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);

    int days; std::cin >> days;
    for (int iDay = 0; iDay < days; iDay++)
    {
        int swim, bugs, work;
        std::cin >> swim >> bugs >> work;
        
        dp[iDay % 2][0] = std::max(dp[(iDay + 1) % 2][1], dp[(iDay + 1) % 2][2]) + swim;
        dp[iDay % 2][1] = std::max(dp[(iDay + 1) % 2][0], dp[(iDay + 1) % 2][2]) + bugs;
        dp[iDay % 2][2] = std::max(dp[(iDay + 1) % 2][0], dp[(iDay + 1) % 2][1]) + work;
    }

    std::cout << std::max(std::max(dp[(days - 1) % 2][0], dp[(days - 1) % 2][1]), dp[(days - 1) % 2][2]) << '\n';

    return 0;
}


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

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


int main()
{
    int n,m; cin >> n >> m;
    int s[m];
    char c[m];
    for(int i = 0; i < m; i++){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    int u = 1;
    for(int i = 0; i < n; i++){
        u *= 10;
    }
    int ans = -1;
    if(u == 10){
        for(int i = 0; i < u; i++){
            bool ok = true;
            string tmp = to_string(i);
            for(int j = 0; j < m; j++){
                if(tmp[s[j]] != c[j]){
                    ok = false;
                }
            }
            if(ok){
                ans = i;
                break;
            }
        }
    }else{
        for(int i = u/10; i < u; i++){
            bool ok = true;
            string tmp = to_string(i);
            for(int j = 0; j < m; j++){
                if(tmp[s[j]] != c[j]){
                    ok = false;
                }
            }
            if(ok){
                ans = i;
                break;
            }
        }
    }
    cout<< ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll = long long;
const ll MOD = 1e9+7; int INF=INT_MAX; ll LLINF = 1LL << 60;
const vector<int> d8x = {1, 0, -1, 0, 1, -1, -1, 1}; vector<int> d8y = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> d4x = {1, 0, -1, 0}; vector<int> d4y = {0, 1, 0, -1};

//

int n,k;
int cnt=0;
vector<int> price;
vector<bool> like(10,true);

void dfs(int num){
    if(num>=n){
        price.push_back(num);
    }else{
        for (int i = 0; i < 10; i++)
        {
            if(like[i]==true && !(i==0 && num==0)){
                dfs(10*num+i);
            }
        }
        
    }
}

int main(){
    cin>>n>>k;
    rep(i,k){
        int a;
        cin>>a;
        like[a]=false;
    }

    dfs(0);
    sort(all(price));

    cout<<price[0]<<endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cctype>
#include<string>

using namespace std;

int main()
{
    long long a=0,b=0,sum=0;
    string s;
    while(1){
        cin >> s;
        sum = 0;
        if(s[0] - '0' == 0 && s.size() == 1) break;
        for(int i = s.size()-1;i >= 0;i--){
            sum += s[i]-'0';
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N;
  string S;
  cin>>N>>S;
  
  int ans=1;
  for(int i=0;i<N-1;++i){
    if(S[i]!=S[i+1])
      ++ans;
  }
  cout<<ans<<endl;
}


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

int main(){
  ll m,n,i,a=1,p=1000000007;
  cin >> n >> m;
  if(abs(m-n)>1){
    cout << 0 << endl;
    return 0;
  }
  for(i=1;i<=n;i++){
    a=(a*i)%p;
  }
  for(i=1;i<=m;i++){
    a=(a*i)%p;
  }
  if(m==n){
    a=(a*2)%p;
  }
  cout << a << endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define ins insert
#define er erase
#define bg begin()
#define ed end()
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define files(name) fin(name".in"); fout(name".out")
#define enter cout << "\n"
#define space cout << " "
#define endl "\n"
#define fi(st,n) for (int i = (st); i <= (n); ++i)
#define fj(st,n) for (int j = (st); j <= (n); ++j)
#define fk(st,n) for (int k = (st); k <= (n); ++k)
#define fq(st,n) for (int q = (st); q <= (n); ++q)
#define fw(st,n) for (int w = (st); w <= (n); ++w)
#define ff(i, st, n) for (int (i) = (st); (i) <= (n); ++(i))
#define ei(st,n) for (int i = (st); i >= (n); --i)
#define ej(st,n) for (int j = (st); j >= (n); --j)
#define ek(st,n) for (int k = (st); k >= (n); --k)
#define ef(i, st, n) for (int (i) = (st); (i) >= (n); --(i))
#define ri(st,n) for (int i = (st); i < (n); ++i)
#define rj(st,n) for (int j = (st); j < (n); ++j)
#define rk(st,n) for (int k = (st); k < (n); ++k)
#define rq(st,n) for (int q = (st); q < (n); ++q)
#define rf(i, st, n) for (int (i) = (st); (i) < (n); ++(i))
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define y1 dsklmlvmd

typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = (int)1e9;
const dbl eps = (dbl) 1e-8;
const int mod = (int) 1e9 + 7;
const int maxn = (int) 1e6 + 5;
//const dbl M_PI = (dbl)2 * (dbl)acos(0);

//cout<<fixed<<setprecision(10);
//srand(time(0));

ll n, a[555][555], t[555], cnt[555], ans, k;
string st;

int main() {
//    fin("t.in");
    sync;
    cin >> n;
    fi(1, n) {
        cin >> st;
        fj(1, n) {
            a[i][j] = (st[j - 1] == '#');
        }
    }
    clean(t);
    fi(1, n) {
        fj(1, n) {
            t[j] = max(t[j], a[i][j]);
        }
    }
    ans = 3 * n;
    fi(1, n) {
        k = 0;
        fj(1, n) {
            k += a[i][j];
        }
        if (k == 0)
            continue;
        if (!t[i])
            --k;
        ans = min(ans, n - k);
    }
    if (ans == 3 * n) {
        cout << -1 << endl;
        return 0;
    }
    clean(cnt);
    fi(1, n) {
        fj(1, n) {
            cnt[j] += a[i][j];
        }
    }
    fj(1, n) {
        if (cnt[j] != n)
            ++ans;
    }

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

Measured memory_bytes: 2432
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
num=0
cnt=0
while cnt<=n:
    tmp=a[num]
    cnt+=1
    if tmp==2:
        break
    else:
        num=tmp-1
if cnt>=n:
    print(-1)
else:
    print(cnt)


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){
  string S;cin>>S;
  REP(i,S.size()){
      S[i] = 'x';
  }
  cout<<S<<endl;
}

int main(){   
  
 solve();

 return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,M; cin >> N >> M;
    vector<vector<P>> edge(N);
    REP(i,M){
        int l,r,d; cin >> l >> r >> d;
        edge[l-1].emplace_back(r-1, d);
        edge[r-1].emplace_back(l-1, -d);
    }

    bool done[N]; REP(i,N) done[i] = false;
    int x[N]; REP(i,N) x[i] = 0;
    queue<P> q;
    REP(i,N){
        if(done[i]) continue;
        q.push(P(i,0));
        while(q.size()){
            P p = q.front(); q.pop();
            int v = p.first, n = p.second;
            if(done[v]){
                if(x[v] != n){
                    cout << "No" << endl;
                    return 0;
                }
                continue;
            }
            done[v] = true;
            x[v] = n;
            for(P pa : edge[v]) q.push(P(pa.first, n+pa.second));
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 11252
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    k = ii()
    a,b = mi()

    for i in range(a,b+1):
        if i%k == 0:
            print('OK')
            return

    print('NG')
    return
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9188
H, W = map(int,input().split())

a = []
for i in range(H):
    Si = input().split()
    a += Si
a1 = a.index('snuke')
a2 = int(a1) % W
a3 = int(a1) // W
print(str(chr(65 + a2)) + str(a3 + 1))


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;

const double EPS = 1e-5;
const int MAX_J = 5001;

int X,Y,Z;
double dp[51][MAX_J];
int V[4];
int event[51], event_A[51];

int main(){
    while(1){
        scanf("%d%d%d",&X,&Y,&Z);
        if(!X)break;

        for(int i = 0; i < X; i++){
            scanf("%d",&V[i]);
        }
        fill(event, event+Y+1, 0);
        for(int i=0;i<Z;i++){
            int N,E,A;
            scanf("%d%d%d",&N,&E,&A);
            event[N] = E;
            event_A[N] = A;
        }
        for(int i=0;i<Y+1;i++){
            for(int j=0;j<MAX_J;j++){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        for(int i=0;i<Y;i++){
            for(int j=0;j<MAX_J;j++){
                for(int k=0;k<X;k++){
                    int nx = min(Y, i + V[k]), mn = j;
                    if(event[nx] == 2) mn += event_A[nx];
                    else if(event[nx] == 3) mn = max(0, j-event_A[nx]);
                    else if(event[nx] == 1) nx = min(Y, nx + event_A[nx]);
                    dp[nx][mn] += dp[i][j] / X;
                }
            }
        }
        double ans = 0;
        for(int i = 0; i < 5000; i++) ans += i * dp[Y][i];
        printf("%d\n", (int)(ans+EPS));
    }
    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbd(a) cout << #a << ": " << a << endl
#define dbd2(a,b) cout << #a << ": " << a << ", " << #b << ": " << b << endl 
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto _i:a) cout << _i << " "; cout << endl
#define adbp(a) for(auto _i:a) cout << _i.first << " " << _i.second << endl;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 998244353
#define N 10000010
#define M 100010
using namespace std;

int main()
{
    fastIO;
    long long a[5], i;
    for(i=0;i<5;i++) cin >> a[i];

    for(i=0;i<5;i++) 
    {
        if(a[i] == 0)
        {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3604
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c,d,n;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>b>>c;
}
void src(){
    cout<<((b-a)==(c-b)? "YES":"NO");
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    for(int i = 111; i <= 999; i += 111) {
        if(i >= N) {
            cout << i << endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include <random>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int D;

int c[27];
int s[366][27];
int last[27];

vector<int> ans;
ll ans_score;

ll calcScore(){
    rep(i,27) last[i] = 0;
    ll score = 0;
    for(int d = 1; d <= D; ++d){
        int t = ans[d];
        score += s[d][t];
        last[t] = d;
        for(int i = 1; i <= 26; ++i){
            score -= c[i] * (d - last[i]);
        }
    }
    return score;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> D;
    for(int i = 1; i <= 26; ++i) cin >> c[i];
    for(int i = 1; i <= D; ++i){
        for(int j = 1; j <= 26; ++j){
            cin >> s[i][j];
        }
    }
    ans.resize(D, 1);
    ans_score = calcScore();
    //local search
    std::random_device rnd;
    std:: mt19937 mt(rnd());
    std::uniform_int_distribution<> randD(1,D);
    rep(_,10000){
        int d = randD(mt);
        for(int q = 1; q <= 26; ++q){
            int old = ans[d];
            ans[d] = q;
            ll score = calcScore();
            if(ans_score > score) ans[d] = old;
            else ans_score = score;
        }
    }
    rep(i,D) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 3708
n = input()
op_cnt = len(n)-1

for i in range(2**op_cnt):
    op = ['-'] * op_cnt
    siki = ''
    for j in range(op_cnt):
        if ((i>>j)&1):
            op[op_cnt-1-j] = '+'
    for moji, ope in zip(n, op+['']):
        siki += (moji+ope)
    if eval(siki) == 7:
        print(siki + '=7')
        break


Measured memory_bytes: 3060
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();  
        int N = r.i();
        int[] A = r.ii();
        int min = Integer.MAX_VALUE;
        for(int a : A){
            int c = 0;
            while(a%2 == 0){
                a /= 2;
                c++;
            }
            if(c < min)
                min = c;
        }
        println(min);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21076
#include<stdio.h>
int main(void)
{
  int a,b,c,d;
  scanf("%d",&a);
  scanf("%d",&b);
  
  int max;
  
  if(a>b){
    c = a;
    a--;
  }
  else{
    c = b;
    b--;
  }
  if(a>b){
    d = a;
  }
  else{
    d = b;
  }
  max = c+d;
  printf("%d",max);
  
  return 0;
  
  
}

Measured memory_bytes: 128
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

s = "ACL"
k = readInt()

print(s*k)

Measured memory_bytes: 9392
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 1005;
const int md = 1e9+7;

void add(int &a, int b)
{
	a += b;
	if(a>= md) a-= md;
}

int mul(int a, int b)
{
	return (1LL*a*b)%md;
}

int bin(int a, int b)
{
	if(b == 0) return 1;
	int x = bin(a, b/2);
	int y = mul(x, x);
	if(b%2) y = mul(y, a);
	return y;
}

int inv(int a)
{
	return bin(a, md-2);
}

int fac[maxn];
int invfac[maxn];

int dp[maxn][maxn];
int n, a, b, c, d;

int f(int i, int a, int k)
{
	int res = fac[i];
	res = mul(res, invfac[i-k*a]);
	res = mul(res, bin(invfac[a], k));
	res = mul(res, invfac[k]);
	return res;
}

int main()
{
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	fac[0] = invfac[0] = 1;
	for(int i = 1; i<= n; i++)
	{
		fac[i] = mul(fac[i-1], i);
		invfac[i] = mul(invfac[i-1], inv(i));
	}
	for(int i = a-1; i<= b; i++) dp[0][i] = 1;
	for(int i = 1; i<= n; i++)
	{
		for(int j = a; j<= b; j++)
		{
			add(dp[i][j], dp[i][j-1]);
			for(int k = c; i-k*j>= 0 && k<= d; k++)
			{
				add(dp[i][j], mul(dp[i-k*j][j-1], f(i, j, k)));
				// printf("f(%d, %d) = %d\n", j, k, f(i, j, k));
			}
			// printf("dp[%d][%d] = %d\n", i, j, dp[i][j]);
		}
	}
	printf("%d\n", dp[n][b]);
}

Measured memory_bytes: 4224
import java.util.*;
public class Main{
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        int[] B = new int[N-1];
        for(int i = 0; i < N-1; i++)B[i] = sc.nextInt();

        A[0] = B[0];
        for(int i = 1; i < N-1; i++){
            A[i] = Math.min(B[i],B[i-1]);
        }
        A[N-1] = B[N-2];
        int sum = 0;
        for(int i = 0; i < N; i++) sum += A[i];
        System.out.println(sum);
    }
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*
*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

signed main() {
  int h, n;
  cin >> h >> n;

  vi a(n);
  rep(i, 0, n) cin >> a[i];

  int sum = 0;
  rep(i, 0, n) sum += a[i];

  if(sum >= h) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 1024
//writer: Sakura
//name: Time Limit Exceeded

#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;

int N,T;
struct Node{
	int c,t;
}a[105];

bool cmp(Node x,Node y){
	if(x.t==y.t)return x.c<y.c;
	return x.t<y.t;
}

int main(){
	scanf("%d %d",&N,&T);
	for(int i=1;i<=N;i++){
		scanf("%d %d",&a[i].c,&a[i].t);
	}
	sort(a+1,a+1+N,cmp);
	int ans=1<<30;
	for(int i=1;i<=N;i++){
		if(a[i].t<=T)ans=min(a[i].c,ans);
	}
	if(ans==1<<30){
		puts("TLE");
		exit(0);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int n, k, s;
    cin >> n >> k >> s;

    for (int i = 0; i < n; ++i) {
        if (i) cout << " ";
        if (i < k) cout << s;
        else if (s < 1000000000) cout << s + 1;
        else cout << 1;
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const int INF_INT = 1 << 25;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
const int loose = 0;
const int tight = 1;

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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve() {
	ll n, kk;
	cin >> n >> kk;
	Array h(n);
	REP(i, n) cin >> h[i];

	vec<vvec<ll>> dp(n + 1, vvec<ll>(kk + 1, vec<ll>(n+1, INF)));//何番目か、変更回数、最後に操作
	dp[0][0][0] = 0;
	REP(i, n) {
		REP(j, kk + 1) {
			REP(k, i+1) {
				ll num = (k == 0) ? h[i] : max(h[i] - h[k-1], 0LL);//操作回数
				chmin(dp[i + 1][j][i + 1], dp[i][j][k] + num);//操作
				if (j+1<=kk) chmin(dp[i + 1][j + 1][k], dp[i][j][k]);//変更
			}
		}
	}
	
	ll ans = INF;
	REP(i, kk + 1) REP(j, n + 1) chmin(ans, dp[n][i][j]);
	cout << ans << endl;
}

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

	solve();

	return 0;
}

Measured memory_bytes: 216832
use std::io;
use std::io::prelude::*;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let uline = line.unwrap();
        let vec: Vec<&str> = uline.split_whitespace().collect();
        let h: usize = vec[0].parse().unwrap_or(0);
        let w: usize = vec[1].parse().unwrap_or(0);
        if h != 0 && w != 0 {
            for _i in 0..h {
                for _j in 0..w {
                    print!("#");
                }
                println!("");
            }
            println!("");
        }
    }
}


Measured memory_bytes: 5028
#include <cstdio>
#include <cmath>

int main()
{
    int N ,cnt;
    int prime;
    bool flag;

    cnt = 0;

    scanf(" %d", &N);

    for (int i = 0; i < N; i++){
        scanf (" %d", &prime);

        if (prime == 2 || prime == 3){
            cnt++;
        }
        else if (prime % 2 != 0){
            for (int j = 2; j <= sqrt(prime); j++){
                if (prime % j == 0){
                    flag = false;
                    break;
                }
                if (prime % j != 0){
                    flag = true;
                }
            }
            if (flag == true){
                cnt++;
            }
        }
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 1024
n = int(input())
h = list(int(i) for i in input().split())
h.insert(0, 0)
count = 0

# print(h)

for i in range(n+2):
    if 1 < i:
        tmp_list = h[0:i]
        my_hotel = h[i-1]
        if max(tmp_list) <= my_hotel:
            count += 1
#        print(i, tmp_list, my_hotel, count)

print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int inP = 0, inW = 0, inG = 0, inY=0;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    string HR;
    cin >> HR;
    if (HR == "P") {
	  inP++;
    } else if (HR == "W") {
	  inW++;
    } else if (HR == "G") {
      inG++;
    } else if (HR == "Y") {
      inY++;
    }
  }
  if (inP && inW && inG && inY) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18, MAX_N = 200000;

class UnionFind {
public:
	vector <lint> par; // 各元の親を表す配列
	vector <lint> siz; // 素集合のサイズを表す配列(1 で初期化)

	// Constructor
	UnionFind(lint sz_) : par(sz_), siz(sz_, 1ll) {
		for (lint i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}
	void init(lint sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1ll);  // resize だとなぜか初期化されなかった
		for (lint i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	lint root(lint x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(lint x, lint y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}

	bool issame(lint x, lint y) { // 連結判定
		return root(x) == root(y);
	}

	lint size(lint x) { // 素集合のサイズ
		return siz[root(x)];
	}
};

lint N, M, K, L;
vector<lint> to[100000];
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> M;
	REP(i, N) {
		cin >> K;
		REP(_, K) {
			cin >> L; L--;
			to[L].push_back(i);
		}
	}
	UnionFind tree(N);
	REP(i, M) {
		REP(j, SZ(to[i]) - 1) {
			if (!tree.issame(to[i][j], to[i][j + 1])) {
				tree.merge(to[i][j], to[i][j + 1]);
			}
		}
	}
	cout << (tree.size(0) == N ? "YES" : "NO") << endl;
}


Measured memory_bytes: 5376
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
#include<map>
#include<algorithm>
using namespace std;




int main() {
	unsigned long long int n,k;
	cin >> n >> k;
	vector<unsigned long long int> data(n);
	
	for(int i=0;i<n;++i){
		cin >> data[i];
	}
	
	sort(data.rbegin(),data.rend());
	
	
	unsigned long long  int res = 0;
	
	for(int i=k;i<n;++i){
		res += data[i];
	}
	
	cout << res << endl;
	
    return 0;
}


Measured memory_bytes: 1792
# coding:UTF-8

antennas = list()

# A〜Eの座標を取り込む　
for _ in range(5):
    antennas.append(int(input()))

distance_range = int(input())

result = 'Yay!'

for i in range(len(antennas) - 1):
    for j in range(1, len(antennas)):
        if distance_range < antennas[j] - antennas[i]:
            result = ':('
            break

print(result)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}
ll const INF=1e6+7;
ll const mx=1e3+7;
ll h,w,c_h,c_w,d_h,d_w;
char maze[mx][mx];
vector<ll>adj[mx];
ll dis[mx][mx];
int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
		cin>>h>>w;
    cin>>c_h>>c_w>>d_h>>d_w;
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        cin>>maze[i][j];
        dis[i][j]=INF;
      }
    }
    // source ki distance 
    dis[c_h][c_w]=0;
    deque<pair<ll,ll>>q;
    q.pb(make_pair(c_h,c_w));
    
    while(!q.empty()){
      ll x,y;
      x=q.front().ff; y=q.front().ss;
      //cout<<x<<" "<<y<<"\n";
      q.pop_front();
      
      //x-2//x+2//y-2//y+2
      for(int i=x-2;i<=x+2;i++){
        for(int j=y-2;j<=y+2;j++){
          if(i>=1&&i<=h&&j>=1&&j<=w&&maze[i][j]=='.'){
            // adjacent abs diff sum will be 1
            if(abs(i-x)+abs(j-y)<=1){
              if(dis[x][y]+0<dis[i][j]){
                dis[i][j]=dis[x][y];
                q.push_front(make_pair(i,j));
              }
              }else{
              if(dis[x][y]+1<dis[i][j]){
                dis[i][j]=dis[x][y]+1;
                q.push_back({i,j});
                }
            }
          }
        }
      }
    }
    if(dis[d_h][d_w]!=INF)
    cout<<dis[d_h][d_w];
    else
    cout<<"-1";
		
		
	}





}




Measured memory_bytes: 12644
// fahadmd16(IIEST Shibpur)
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define db double
#define pll pair<ll, ll>
#define ALL(a) (a).begin(),(a).end()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define forn(i, n) for (ll i = 0; i < n; i++)
#define forn1(i, n) for (ll i = 1; i < n; i++)
#define forab(i,a,b) for(ll i=a;i<b;i++)
#define clr(x) memset(x, 0, sizeof(x))
#define count_bit(x) __builtin_popcount(x)
#define endl "\n"
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define trace(v) for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define eps 1e-10
#define nedl endl
const ll sz = 1e6;
const ll mod = 1e9+7;
typedef vector<ll> VL;
typedef vector<pll > VLL;
typedef vector<vector<ll> > VVL;
 
ll power(ll n,ll k,ll m){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%m;
        k/=2;
        n=(n*n)%m;
    }
    return ans;
}



int main() {
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll T=1;//cin>>T;
    
    while(T--){
        // ll coin[]={500,100,50,10,5};
        // ll happy[]={1000,0,0,0,5};
        ll x;cin>>x;
        ll h1=x/500 * 1000;
        ll h2=(x%500)/5 * 5;
        //ll rem=(x%500)%5;
        cout<<h1+h2<<endl;

    }
    return 0;
}


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

const int mod = 1000000007;
int fact[10004];

inline int mul(int a, int b){
	long long ret = 1ll*a*b;
	return ret % mod;
}

inline int power(int a, int p){
	if(p == 0)	return 1;
	int ret = power(a, p/2);
	ret = mul(ret, ret);
	if(p % 2)	ret = mul(ret, a);
	return ret;
}

inline int divide(int a, int b){
	return mul(a, power(b, mod-2));
}

inline int comb(int n, int r){
	return divide(fact[n],mul(fact[n-r], fact[r]));
}

int main() {
	fact[0] = 1;
	for(int i = 1; i<= 10000;i++)	fact[i] = mul(fact[i-1], i);
	int n, k;
	cin>>n>>k;
	int slot = n - k + 1;
	for(int i = 1; i<=k;i++){
		if(slot < i){
			cout<<"0\n";
			continue;
		}
		cout<<mul(comb(slot, i), comb(k - 1, k - i))<<'\n';
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  N *= 2;
  int L[N];
  for (int i = 0; i < N; i++) cin >> L[i];
  
  int count = 0;
  
  priority_queue<int> Que;
  for (int i = 0; i < N; i++){
    Que.push(L[i]);
  }
  
  while(!Que.empty()){
    Que.pop();
    if (Que.empty()) break;
    count += Que.top();
    Que.pop();
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	double r,sx,sy,tx,ty;
};

struct Point{
	void set(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}
	double x,y;
};

typedef Point Vector;

struct Segment{
	void set(double x1,double y1,double x2,double y2){
		p1.x = x1;
		p1.y = y1;
		p2.x = x2;
		p2.y = y2;
	}
	Point p1,p2;
};

typedef Segment Line;

double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
	return a.x*b.x + a.y*b.y;
}

Point calc_minus(Point a,Point b){
	Point ret;

	ret.x = a.x-b.x;
	ret.y = a.y-b.y;

	return ret;
}

double calc_len(Vector a){
	return sqrt(a.x*a.x+a.y*a.y);
}

double getDistanceLP(Line l,Point p){
	return fabs(cross(calc_minus(l.p2,l.p1),calc_minus(p,l.p1))/calc_len(calc_minus(l.p2,l.p1)));
}

double getDistanceSP(Segment s,Point p){
	if(dot(calc_minus(s.p2,s.p1),calc_minus(p,s.p1)) < 0.0)return calc_len(calc_minus(p,s.p1));
	if(dot(calc_minus(s.p1,s.p2),calc_minus(p,s.p2)) < 0.0)return calc_len(calc_minus(p,s.p2));
	return getDistanceLP(s,p);
}

bool dp[65536];

int main(){

	int POW[17];
	for(int i = 0; i < 17; i++)POW[i] = pow(2,i);

	int N;
	scanf("%d",&N);
	Info info[N];

	for(int i = 0; i < N; i++){
		scanf("%lf %lf %lf %lf %lf",&info[i].r,&info[i].sx,&info[i].sy,&info[i].tx,&info[i].ty);
	}

	for(int state = 0; state < POW[N]; state++)dp[state] = false;
	dp[0] = true;

	int ans = 0,tmp_num;
	bool is_init_pos[N];
	Segment move_line;
	Point point;

	bool FLG;

	for(int state = 0; state < POW[N]; state++){
		if(!dp[state])continue;
		tmp_num = 0;

		for(int loop = 0; loop < N; loop++){
			if(state & (1 << loop)){
				is_init_pos[loop] = false;
				tmp_num++;
			}else{
				is_init_pos[loop] = true;
			}
		}
		ans = max(ans,tmp_num);

		for(int i = 0; i < N; i++){
			if(is_init_pos[i] == false || dp[state+POW[i]] == true)continue;

			move_line.set(info[i].sx,info[i].sy,info[i].tx,info[i].ty);
			FLG = true;

			for(int k = 0; k < N; k++){
				if(i == k)continue;

				if(is_init_pos[k]){
					point.set(info[k].sx,info[k].sy);
				}else{
					point.set(info[k].tx,info[k].ty);
				}

				if(getDistanceSP(move_line,point) < info[i].r+info[k].r){
					FLG = false;
					break;
				}
			}

			if(FLG){
				dp[state+POW[i]] = true;
			}
		}
	}

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

	return 0;
}

Measured memory_bytes: 3440
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct node{
  int key;
  struct node *next , *prev;
}Node;

Node *nil;

Node* search(int key){
  Node *cur=nil->next;
  while(cur!=nil&&cur->key!=key){
    cur=cur->next;
  }
  return cur;
}

void init(){
  nil=(Node *)malloc(sizeof(Node));
  nil->next=nil;
  nil->prev=nil;
}

void print() {
  Node *cur=nil->next;
  int count=0;
  while(1){
    if(cur==nil) break;
    if(count++>0) printf(" ");
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t){
  if(t==nil ) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  deleteNode(nil->prev);
}
void deleteKey(int key){
  deleteNode(search(key));
}

void insert(int key) {
  Node *x =(Node *)malloc(sizeof(Node));
  x->key=key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key,n,i,size=0;
  char com[20];
  int np=0,nd=0;
  scanf("%d",&n);
  init();
  for(i = 0;i<n;i++) {
  scanf("%s%d",com,&key);
  if(com[0] == 'i') {
    insert(key);
    np++;
    size++;
  }
  else if(com[0]=='d') {
    if(strlen(com)>6) {
      if(com[6]=='F') deleteFirst();
      else if(com[6]=='L') deleteLast();
    }
    else {
      deleteKey(key); nd++;
    }
    size--;
  }
}
print();
return 0;
}

Measured memory_bytes: 31788
#include <cstdio>

typedef unsigned long long ull;

const ull LIMIT=1000000000000000000llu;

int main(){
    int N;
    scanf("%d",&N);

    ull ans=1ull;
    bool overflowed=false;
    for(int i=0;i<N;i++){
        ull temp;
        scanf("%llu",&temp);
        if (temp==0){
            puts("0");
            return 0;
        }

        if (ans!=0&&(LIMIT/ans)<temp) overflowed=true;

        ans=ans*temp;
    }

    if (overflowed){
        puts("-1");
        return 0;
    }else printf("%llu\n",ans);

    return 0;
}

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

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

    //good luck, kittu
    int n; string s;
    cin>>n>>s;
    if(n&1) return cout<<"No\n", 0;

    bool ok = 1;
    for(int i = 0; i<n/2; i++) if(s[i]!=s[i+n/2]) ok = 0;
    cout<<(ok?"Yes\n":"No\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
#include <cmath>
#include <unordered_map>
#include <algorithm>
#include <stack>
#include <unordered_set>
using namespace std;

int main () {
	vector<int> v;
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e;
	v.push_back(a);
	v.push_back(b);
	v.push_back(c);
	v.push_back(d);
	v.push_back(e);

	int res = 10;
	for (int i = 0; i < 5; i++) {
		if (v[i] % 10 != 0 && res > v[i] % 10) {
			res = v[i] % 10;
		}
		if (v[i] % 10 != 0) {
			v[i] = v[i] / 10 * 10 + 10;
		}
	}
	cout << v[0] + v[1] + v[2] + v[3] + v[4] - 10 + res;
}

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

int n;
int a[200000];
int cnt[1000001];
bool ng[1000001];

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	for (i = 1; i <= 1000000; i++) {
		if (cnt[i] > 0) {
			for (j = i * 2; j <= 1000000; j += i) {
				ng[j] = true;
			}
		}
	}
	
	int ans = 0;
	for (i = 1; i <= 1000000; i++) {
		if (cnt[i] == 1 && !ng[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005
int f[1001001] = {};
int main() {
    int n;
    cin >> n;

    
    rep(i,n){
        int a;
        cin >> a;
        f[a]++;
    }

    int ma = 1;
    srep(i,2,1000001){
        int tmp = 0;
        srep(j,1,1001001){
            if(i*j>1000000)break;
            tmp += f[i*j];
        }
        ma = max(ma,tmp);
    }

    if(ma == n){
        cout << "not coprime" << endl;
    }else if(ma == 1){
        cout << "pairwise coprime" << endl;
    }else{
        cout << "setwise coprime" << endl;
    }
    return 0;
}




Measured memory_bytes: 7544
#include <iostream>
#include <string.h>
#include <algorithm>
#include <math.h>
using namespace std;


int main() {
    long long n;
    long long ans[10000001];
    memset(ans, 0, sizeof(ans));
    scanf("%lld", &n);
    long long nCount = 0;
    for(long long i=1; i<=n; i++) {
        for(long long j=0; j<=n; j+=i) {
            ans[j]++;
        }
        // printf("%lld\n", ans);
    }
    for(long long i=1; i<=n; i++) {
        nCount += ans[i] * i;
    }
    printf("%lld\n", nCount);
    return 0;
}

Measured memory_bytes: 81952
import networkx as nx
import itertools

N, M = map(int, input().split())
G = nx.Graph()
G.add_weighted_edges_from([map(int, input().split()) for _ in range(M)])
S = nx.floyd_warshall(G)

ans = M
for i, j, d in G.edges(data=True):
    for s, t in itertools.combinations(G.nodes(), 2):
        if S[s][i] + d['weight'] + S[j][t] == S[s][t]:
            ans -= 1
            break
print(ans)

Measured memory_bytes: 55060
#include <bits/stdc++.h>
using namespace std;
long long w[1010];
long long v[1010];
int N;
long long dp[110][100010];
long long mo(int pos , long long W){
    if(W < 0) return -1e9;
    if(pos == N){
        return 0;
    }
    long long &re = dp[pos][W];
    if(re != -1) return re;
    
    re = max( mo(pos+1 , W) , mo(pos+1 , W-w[pos]) + v[pos]);
    return re;
}   
int main(){
    int W;
    while(cin>>N>>W){
        memset(dp,-1,sizeof dp);
        for(int i = 0 ; i < N ; i++){
            cin>>w[i]>>v[i];
        }
        cout<<mo(0,W)<<"\n";
    }
    return 0;
}


Measured memory_bytes: 89592
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

  ll n, m, a = 0;
  cin >> n >> m;
  rep(i, m) {
    ll t;
    cin >> t;
    a += t;
  }
  if (n - a >= 0) cout << n - a << endl;
  else cout << -1 << endl;

}


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

using namespace std;

#define frei(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define fred(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define fri(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define frd(i,n) for (int i = (n) - 1; i >= 0; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )

#define uint64 unsigned long long
#define int64 long long
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define ff first
#define ss second
#define pr pair

#define BIT(n) (1<<(n))
#define AND(a,b) ((a) & (b))
#define OR(a,b) ((a) | (b))
#define XOR(a,b) ((a) ^ (b))
#define sqr(x) ((x) * (x))

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<pii> vii;
typedef vector<int> vi;

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 5005



int main(int argc, char const *argv[])
{
    /* code */
    int n, k;
    cin >> n >> k;
    int a[n+1];
    int dp[n+1];
    for(int i = 1; i <= n; i++) {
        dp[i] = 1e9;
    }
    dp[1] = 0;
    //cout << endl;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i < n; i++) {
        for(int j = i + 1; j <= i + k && j <= n; j++) {
            dp[j] = min(dp[j], dp[i] + abs(a[j] - a[i]));
        }
    }
    cout << dp[n] << endl;
    return 0;
}


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

const int MAX = 500500;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll PER(int n, int k) {
    if (n < 0 || k < 0 || n < k) return 0;
    return fac[n] * finv[n - k] % MOD;
}

int main() {
    COMinit();

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

    ll ans = 0ll;
    for (int i = 0; i <= n; i++) {
        if (i % 2) ans -= COM(n, i) * PER(m, i) % MOD * PER(m - i, n - i) % MOD * PER(m - i, n - i) % MOD;
        else ans += COM(n, i) * PER(m, i) % MOD * PER(m - i, n - i) % MOD * PER(m - i, n - i) % MOD;
        ( ans += MOD ) %= MOD;
    }

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

Measured memory_bytes: 15368