akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<string> a(n);
    vector<string> z(n);
    string s;
    REP(i, n) {
        cin >> s;
        REPS(c, s) {
            if (c == '?') {
                a[i] += 'a';
                z[i] += 'z';
            } else {
                a[i] += c;
                z[i] += c;
            }
        }
    }
    SORT(a);
    SORT(z);
    string t;
    cin >> t;
    int r = distance(a.begin(), upper_bound(ALL(a), t));
    int l = distance(z.begin(), lower_bound(ALL(z), t));
    FOR(i, l + 1, r + 2) cout << i << (i == r + 1 ? endl : ' ');
}



Measured memory_bytes: 1536
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> bs(N - 1);
  F0R(i, N - 1) {
    cin >> bs[i];
  }
  int a = bs[0];
  int result = a;
  FOR(i, 1, N - 1) {
    result += min(a, bs[i]);
    a = bs[i];
  }
  result += bs.back();
  cout << result;
}
#endif


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
using namespace std;
int sum[10200]={0},a[10020],n;
int main()
{
    scanf("%d",&n);
    for(int i = 1; i <= n; i ++){
        scanf("%d",&a[i]);
    }
    sum[0] = 1;
    for(int j = 1; j <= n; j ++)
        for(int i = 10000; i >= a[j]; i --){
            if(sum[i - a[j]] == 1)
                sum[i] = 1;
        }
    int i;
    for(i = 10000;i > 0; i --){
        if(sum[i] == 1 && i % 10 != 0)
            break;
    }
    printf("%d",i);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define EPS 1e-10

#define RIGHT 1
#define LEFT  -1

typedef complex<double> P;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

P intersection_ll(P a1,P a2,P b1,P b2){
  P a=a2-a1,b=b2-b1;
  return a1 + a*cross(b,b1-a1)/cross(b,a);
}



int ccw(P a,P b){
  if (cross(a,b)<0 )return RIGHT;
  else if ( cross(a,b)>0)return LEFT;
  return 2;
}

vector<P> Convex_Cut(vector<P> in,int n,P a1,P a2){
  vector<P> ret;
  rep(i,n){
    P now = in[i],next=in[(i+1)%n];
    if ( ccw(a1-a2,now-a2)==LEFT)ret.push_back(now);
    if ( ccw(a1-a2,now-a2)*ccw(a1-a2,next-a2)< 0 )
      ret.push_back( intersection_ll(a1,a2,now,next));
  }
  
  return ret;
}

double calc(double a,double b){return sqrt(a*a+b*b);}


int cut(P *in,int n,double r){
  vector<P> a;
  rep(i,n)a.push_back(in[i]);
  
  rep(i,n && a.size() ){
    P tmp=in[(i+1)%n]-in[i];
    complex<double> e(-tmp.imag(),tmp.real());
    e=e/abs(e)*r;
    a = Convex_Cut(a,a.size(),in[(i+1)%n]+e,in[i]+e);    
  }

  return a.size();
}

double solve(P *in,int n){
  double small=0,large=0,mid=0;
  rep(i,n){
    REP(j,i+1,n)large=max(large,calc(in[i].real()-in[j].real(),in[i].imag()-in[j].imag()));
  }
  

  while(small<=large){
    mid = (small+large)/2; 
    
    if ( cut(in,n,mid) == 0)large=mid-1e-6;
    else small=mid+1e-6;
  }
  return mid;
}


main(){
  int n;
  while(cin>>n&&n){
    P in[n];
    rep(i,n)cin>>in[i].real() >> in[i].imag();
    printf("%.6lf\n",solve(in,n));
  }

}

Measured memory_bytes: 0
#include <cstdio>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cctype>
#include <cfloat>

#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <list>

#include <iostream>
#include <sstream>
#include <fstream>

#include <algorithm>
using namespace std;
#ifdef ONLINE_JUDGE
    #define debug
    #define log(message)
#else
    #define debug printf("passing [%s] in line %d\n", __FUNCTION__, __LINE__)
    #define log(message) puts(message)
#endif
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
void closeSync() {ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0);}
template<class T> inline void read(T &x) {
    x = 0; int f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') f &= (ch ^ '-'), ch = getchar();
    while('0' <= ch && ch <= '9') x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
    x = f ? x : -x;
}

typedef long long ll;
typedef long double ld;

int n;

ll mem[100];

ll f(int x) {
	if(x == 0) return 2;
	if(x == 1) return 1;
	if(mem[x]) return mem[x];
	return mem[x] = f(x - 1) + f(x - 2);
}

int main() {
	read(n);
	printf("%lld\n", f(n));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = 0;
    Forn(i, n) if(i%3 && i%5) ans += i;
    cout << ans << endl;
}


Measured memory_bytes: 3600
/*
    Reference :-
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
//ll mod=1000000007;
ll mod=100000000;
ll power(ll n,int k){
    ll ans=1;
    while(k){
        if(k&1)ans=(ans*n)%mod;
        k/=2;
        n=(n*n)%mod;
    }
    //ans=(ans-1+mod)%mod;
    return ans;
}
int main() {
    //std::ios::sync_with_stdio(false);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    if(n&1){
        cout<<n/2;
    }
    else cout<<(n/2)-1;


	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int a;
  for(int i=1; i<=10000; i++) {
      cin >> a;
      if(a==0) {
          return 0;
      }
      cout << "Case " << i << ": " <<  a <<  endl; 
  }
}


Measured memory_bytes: 3080
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
    k <- getInt
    s <- getLine
    let n = length s
        ans | n <= k = s
            | otherwise = (take k s) ++ "..."
    putStrLn ans

Measured memory_bytes: 3776
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long ll;

const int MAXN = 301;
int N, M, Q;
ll L, dist1[MAXN][MAXN] = {0}, dist2[MAXN][MAXN] = {0};

void floyd(ll (&dist)[MAXN][MAXN])
{
    for (int k = 1; k <= N; k++)
    {
        for (int i = 1; i <= N; i++)
        {
            for (int j = 1; j <= N; j++)
            {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main()
{
    cin >> N >> M >> L;
    fill(&dist1[0][0], &dist1[MAXN - 1][MAXN], (ll)1e18);
    for (int i = 1; i <= N; i++)
        dist1[i][i] = 0;
    for (int i = 1; i <= M; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        dist1[a][b] = c;
        dist1[b][a] = c;
    }

    floyd(dist1);

    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            if (i == j)
                dist2[i][j] = 0;
            else if (dist1[i][j] <= L)
                dist2[i][j] = 1;
            else
                dist2[i][j] = (ll)1e18;
        }
    }

    floyd(dist2);

    cin >> Q;
    for (int i = 1; i <= Q; i++)
    {
        int a, b;
        cin >> a >> b;
        if (dist2[a][b] == (ll)1e18)
            cout << -1 << endl;
        else
            cout << dist2[a][b] - 1 << endl;
    }
}


Measured memory_bytes: 1920
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] H = new int[n + k + 10];
        for(int i = 0; i < n; i++) H[i] = Integer.parseInt(sc.next());
        int[] dp = new int[n + k + 10];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = 0;
        for(int i = 0; i < n; i++) {
            for(int j = 1; j <= k; j++) {
                dp[i + j] = Math.min(dp[i + j], dp[i] + Math.abs(H[i] - H[i + j]));
            }
        }
        System.out.println(dp[n - 1]);
    }
}


Measured memory_bytes: 49112
sr = input()
n = len(sr)

blist = []
for i in range(2**(n-1)):
    blist.append(list(map(int,list(bin(i)[2::].zfill(n-1)))))

ssum = 0
for k,num in enumerate(blist):
    bi = 0
    bsum = 0
    for i,j in enumerate(num):
        if j == 1:
            bsum += int(sr[bi:i+1])
            bi = i+1
        if i == (len(num)-1):
            bsum += int(sr[bi:])
    ssum += bsum
print(ssum)

Measured memory_bytes: 3064
// Author: πα

#include <bits/stdc++.h>
using namespace std;
#define long int64_t

const int N = 1e5 + 5;
int a[N], m;
const int INF = (1LL << 30) - 1;

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, i, d;
    cin >> n;
    for(i = 0; i < n; ++i)
    {
        cin >> d;
        d = -d;
        int idx = upper_bound(a, a+m, d) - a;
        if(idx == m)
            m++;
        a[idx] = d;
    }
    cout << m;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
using namespace std;

#define fi first
#define se second
typedef long long LL;
typedef long double LD;
#define mod 1000000007

LL N,T[1000100];

int main(){
    cin >> N;
    T[0]=1;
    T[1]=N;

    int i; LL sum=0;
    for (i=2; i<=N; i++){
        T[i]=T[i-1];
        T[i]=(T[i]+(N-1)*(N-1))%mod;
        T[i]=(T[i]+sum)%mod;
        T[i]=(T[i]+N-i+1)%mod;
        sum=(sum+T[i-2])%mod;
    }

    cout << T[N] << "\n";
    return 0;
}


Measured memory_bytes: 8064
K = int(input())


def is_lunlun(i):
    result = -1
    n = [ord(c) - 48 for c in str(i)]
    for j in range(len(n) - 1):
        if abs(n[j] - n[j + 1]) <= 1:
            continue
        if n[j] < n[j + 1]:
            for k in range(j + 1, len(n)):
                n[k] = max(n[k - 1] - 1, 0)
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 1))
        else:
            result = int(''.join(str(k) for k in n))
            result += 10 ** (len(n) - (j + 2))
        break
    return result


i = 1
while True:
    # print(i)
    t = is_lunlun(i)
    if t == -1:
        K -= 1
        if K == 0:
            print(i)
            exit()
        i += 1
    else:
        i = t


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


int main() {
  string S;
  cin >> S;
  vector<int> dp(S.size(), 0);
  dp[0] = 1;
  for (int i = 1; i < S.size(); ++i) {
    char last_si = S[i - 1];
    char cur_si = S[i];
    if (cur_si == last_si) {
      if (i == 1) {
        dp[i] = dp[i - 1];
      } else {
        dp[i] = dp[i - 3] + 2;
      }
    } else {
      dp[i] = dp[i - 1] + 1;
    }
  }
  cout << dp[S.size() - 1] << endl;
}

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

int L;

int x[Sz];
            
const int N = 1e5 + 1;
   
int nxt[18][N];
           
int main()
{                                  
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;    
  for (int i = 1; i <= n; i++)
    cin >> x[i];
  cin >> L;
  for (int i = n - 1; i >= 1; i--) {
    static int ptr = n;
    while (x[ptr] - x[i] > L)
      ptr--;                        
    nxt[0][i] = ptr;    
    for (int j = 1; j <= 17; j++)
      nxt[j][i] = nxt[j - 1][nxt[j - 1][i]];
  }
        
  int q; cin >> q;
  while (q--) {
    int l, r; cin >> l >> r;

    if (l > r)
      swap (l, r);

    int ans = 0;
    for (int i = 17; i >= 0; i--) {  
      if (nxt[i][l] && nxt[i][l] < r)
        l = nxt[i][l], ans += (1<<i);
    }
      ans++; 
    cout << ans << endl;
  }
         
                           



  return 0;
}






// Coded by Z..



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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>

int main(){
    ll K,A,B; cin>>K>>A>>B;
    ll ans = K+1;
    if(A<B){
        K -= (A-1);
        if(K>0){
            if(K%2==0){
                chmax(ans, A+(B-A)*(K/2) );
            }else{
                chmax(ans, A+(B-A)*(K/2)+1);
            }
        }
    }
    cout << ans << "\n";
        
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
// ¹öª¢çÈ¢ê
vector<Weight> dijkstra2(const Graph &g, int s) {
  vector<Weight> dist(g.size(), INF);
  dist[s] = 0;
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (dist[e.dst] < e.weight) continue;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
  return dist;
}

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

  int ba[w][h];
  REP(y,h) {
    REP(x,w) {
      char c;
      cin >> c;
      ba[x][y] = c-'0';
    }
  }
  Graph g(h*w);
  REP(y,h) {
    REP(x,w) {
      if (y<h-1) {
        g[x*h+y].push_back(Edge(x*h+y, x*h+y+1, ba[x][y+1]));
      }
      if (x<w-1) {
        g[x*h+y].push_back(Edge(x*h+y, (x+1)*h+y, ba[x+1][y]));
      }
    }
  }
  printf("%d\n", dijkstra2(g,0)[h*w-1]);
}

Measured memory_bytes: 0
#include <cstdio>

typedef long long ll;

const int MAXN = 1E5 + 10;
const int MOD = 1E9 + 7;

int main(){
	int n;
	scanf("%d", &n);
	ll ans = 1;
	int res = 0;
	for (int x, i = 1; i <= n; ++i){
		scanf("%d", &x);
		++res;
		if (x < 2 * res - 1)
			ans = ans * res % MOD, --res;
	}
	for (; res; --res)
		ans = ans * res % MOD;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = sc.nextInt();
        }
        long start = System.nanoTime();
        System.out.println(solve(n,h));
        long end = System.nanoTime();
        System.err.println("execution time: " + ((end-start)/1_000_000) + "ms");
    }
    private static int solve(int n, int[] h) {
        int u = 0;
        int v = Math.abs(h[1]-h[0]);
        for (int i = 2; i < n; i++) {
            int tmp = v;
            v = Math.min(v+Math.abs(h[i]-h[i-1]),u+Math.abs(h[i]-h[i-2]));
            u = tmp;
        }
        return v;
    }
}


Measured memory_bytes: 50816
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	int a[4];
	a[3]=n%10;
	n/=10;
	a[2]=n%10;
	n/=10;
	a[1]=n%10;
	n/=10;
	a[0]=n%10;
	if (a[0]+a[1]+a[2]+a[3]==7)
		cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	else if (a[0]+a[1]+a[2]-a[3]==7)
		cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	else if (a[0]+a[1]-a[2]+a[3]==7)
		cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	else if (a[0]+a[1]-a[2]-a[3]==7)
		cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	else if (a[0]-a[1]+a[2]+a[3]==7)
		cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	else if (a[0]-a[1]+a[2]-a[3]==7)
		cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3]<<"=7"<<endl;
	else if (a[0]-a[1]-a[2]+a[3]==7)
		cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3]<<"=7"<<endl;
	else if (a[0]-a[1]-a[2]-a[3]==7)
		cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3]<<"=7"<<endl;

	return 0;
}

Measured memory_bytes: 256
// ABC088D
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <functional>
#include <set>
#include <iterator>
#include <queue>

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

int N;
int ans[] = {11, 31, 41, 61, 71, 3461, 101, 131, 151, 181,
             191, 211, 241, 251, 271, 281, 311, 331, 401, 421,
             431, 461, 491, 521, 541, 571, 601, 631, 641, 661,
             691, 701, 751, 811, 821, 881, 911, 941, 971, 991, 
             1021, 1051, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1321,
             1381, 1451, 1531, 1571, 1721, 1871};

int main() {
   cin >> N;
   for (int i=0;i<N;i++) {
      printf("%d", ans[i]);
      if(i < N-1) {
         printf(" ");
      } else {
         printf("\n");
      }
   }
}

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

H,W = list(map(int, input().rstrip().split()))
a_list = [list(input().strip()) for _ in range(H)]
#-----

b_list=[ ["#" for c in range(W+2)] for r in range(H+2) ]

for i in range(H):
    for j in range(W):
        b_list[i+1][j+1] = a_list[i][j]

for li in b_list:
    print(*li,sep="")


Measured memory_bytes: 4596
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll M = pow(10, 9) + 7;

vector<ll> fac(20000001);  //n!(mod M)
vector<ll> ifac(20000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n)
{ //x^n(mod M)
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
//conbination
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % M;
    return tmp * fac[a] % M;
}
ll nCr(ll n, ll m) {
    // cout << n << " - " << m << endl;
    m = min(m, n-m);
    if (m == 0) return 1;
    ll num = 1, dem = 1;
    for(ll i = 1; i <= m; i++) {
        num = (num*(n+1-i));
        num = num / i;
    }
    return num;
}
ll n,k;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i <= 2000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % M;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M)
    }
    cin >> n>>k;
    ll ans=0;
    ll temp=1;
    for (int i = 0; i <min(k+1,n); i++)//0人の個数
    {
        temp=comb(n,i)*comb(n-1,n-1-(n-1-i));
        temp%=MOD;
        ans+=temp;
        ans%=MOD;
    }
    cout << ans << "\n";
}
//https://qiita.com/drken/items/f2ea4b58b0d21621bd51#2-2-玉区別しない箱区別1個以上


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

int main(){
	int N, K, ans = 1;
	cin>>N>>K;
	for(int i = 1; i <= N; i ++){
		if(ans * 2 < ans + K)ans = ans * 2;
		else ans = ans + K;
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = sorted(list(map(int,input().split())))
cnt = []
for i in range(m-1):
  cnt.append(x[i+1] - x[i])
cnt = sorted(cnt)
if n == 1:
  print(x[-1] - x[0])
else:
  print(sum(cnt[:-(n-1)]))

Measured memory_bytes: 13968
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] modCounts = new int[3];
		for (int i = 0; i < n; i++) {
		    modCounts[sc.nextInt() % 3]++;
		}
		if (modCounts[1] == 0 && modCounts[2] == 0) {
		    System.out.println(1);
		} else if (modCounts[1] == modCounts[2]) {
		    System.out.println(n);
		} else if (modCounts[1] < modCounts[2]) {
		    modCounts[2] -= modCounts[1];
		    System.out.println(Math.min(n, n - (modCounts[2] - 3)));
		} else {
		    modCounts[1] -= modCounts[2];
		    System.out.println(Math.min(n, n - (modCounts[1] - 3)));
		}
	}
}



Measured memory_bytes: 166304
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long[][] xyzs = Enumerable.Repeat(0, nm[0]).Select(_ => Console.ReadLine().Split().Select(long.Parse).ToArray()).ToArray();
        long max = 0;
        for (int i = 0; i <= 1; i++)
        {
            for (int j = 0; j <= 1; j++)
            {
                for (int k = 0; k <= 1; k++)
                {
                    List<Tuple<long, long[]>> a = new List<Tuple<long, long[]>>();
                    foreach (var xyz in xyzs)
                    {
                        long score = (i == 0 ? 1 : -1) * xyz[0] + (j == 0 ? 1 : -1) * xyz[1] + (k == 0 ? 1 : -1) * xyz[2];
                        a.Add(new Tuple<long, long[]>(score, xyz));
                    }
                    long s = 0;
                    for (int g = 0; g < 3; g++)
                    {
                        s += Math.Abs(a.OrderByDescending(f => f.Item1).Take(nm[1]).Sum(p => p.Item2[g]));
                    }
                    max = Math.Max(max, s);
                }
            }
        }
        Console.WriteLine(max);
    }
    
}

Measured memory_bytes: 14048
// AOJ 0533
#include<algorithm>
#include<cstdio>

int a[10], b[10];

int main()
{
	for( int i = 0; i != 10; ++i )
		scanf( "%d", a+i );
	for( int i = 0; i != 10; ++i )
		scanf( "%d", b+i );

	std::sort( a, a+10 );
	std::sort( b, b+10 );

	printf( "%d %d\n", a[9]+a[8]+a[7], b[9]+b[8]+b[7] );

	return 0;
}

Measured memory_bytes: 1040
def search_root(l, n):
    i = n
    while l[i] != i:
        i = l[i]
    return i


def set_root(l, root_index, start_index):
    i = start_index
    while l[i] != root_index:
        tmp = i
        i = l[i]
        l[tmp] = root_index


def func(n):
    return (n * (n - 1)) // 2


node_size, input_size = [int(i) for i in input().split()]

br = []
for _ in range(input_size):
    br.append([int(i) for i in input().split()])

cnt_list = [0]
size_list = [1 for _ in range(node_size + 1)]
node_list = [i for i in range(node_size + 1)]

for i in range(1, input_size + 1):
    node1, node2 = br[-i]

    root1, root2 = search_root(node_list, node1), search_root(node_list, node2)

    if root1 == root2:
        cnt_list.append(cnt_list[-1])
    else:
        cnt_list.append(cnt_list[-1] + (size_list[root1] * size_list[root2]))
        if size_list[root1] < size_list[root2]:
            node_list[root1] = root2
            size_list[root2] += size_list[root1]
        else:
            node_list[root2] = root1
            size_list[root1] += size_list[root2]

val = func(node_size)
for i in cnt_list[::-1][1:]:
    print(val - i)

Measured memory_bytes: 30892
#include<stdio.h>
int main(){
	int n,t,m,j;
	char s[100005];
	int c[100005];
	while(~scanf("%d",&n)){
		c[100005]={0};
		scanf("%s",s);
		m=0;
		t=0;
		j=0;
		for(int i=0;i<n;i++)
		{
			if(s[i]==s[i+1])
			c[j]++;
			else
			j++;
		}
		printf("%d\n",j);
	}
	return 0;
} 

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.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 namespace std;

//ABC136
signed main(void){

    int a, b, c; cin >> a >> b >> c;
    int t = a - b;
    cout << max<int>(c - t, 0) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX = 18;
const int INF = 1<<29;

int t[MAX][MAX], n;
int dp[1<<16];

int solve(){
  for(int i = 0 ; i < (1<<n) ; i++) 
    dp[i] = INF;

  dp[0] = 0;
  for(int i = 0 ; i < (1<<n) ; i++){
    for(int j = 0 ; j < n ; j++){

      if(!(i & (1<<j))){
	dp[i + (1<<j)] = min(dp[i + (1<<j)], t[j][0] + dp[i]);
	for(int k = 0 ; k < n ; k++){
	  if(i & (1<<k)){
	    dp[i + (1<<j)] = min(dp[i + (1<<j)],dp[i]+t[j][k+1]);
	  }
	}
      }

    }
  }

  return dp[(1<<n)-1];
}

int main(){

  while(cin >> n ,n){
    memset(t,0,sizeof(t));

    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j <= n ; j++){
	cin >> t[i][j];
      }
    }    
    cout << solve() << endl;

  }

  return 0;
}

Measured memory_bytes: 1416
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(LL i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAXN = 1e5 + 47;
const LL MAX = 47;

LL n;
LL m;
LL ans;
VI g[MAXN];
char used[MAXN];
bool bipartite = 1;

void dfs(int v, char color)
{
	used[v] = color;
	for (auto i : g[v])
	{
		if (used[i] == 0)
			dfs(i, 3 - color);

		if (used[i] == used[v])
			bipartite = 0;
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	cin >> n >> m;
	int u, v;
	FOR(i, 0, m)
	{
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	dfs(0, 1);
	if (bipartite)
	{
		ans = 0;
		int cnt1 = 0;
		FOR(i, 0, n)
			if (used[i] == 1)
				++cnt1;

		ans = cnt1;
		ans *= (n - cnt1);
	}
	else
		ans = n * (n - 1) / 2;

	ans -= m;
	ans = max(ans, 0LL);
	cout << ans;
	cin >> n;
	return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
    long long n, num = 1;
    cin >> n;
    if (n > 2)
        num++;
    for (long long k = 2; k <= sqrt(n); k++)
    {
        if ((n - 1) % k == 0)
            num += 2;
        if (k * k == n - 1)
            num--;
        
        long long m = n;
        if (n % k == 0)
        {
            while (m >= k)
                if (m % k == 0)
                    m /= k;
                else
                    m %= k;
            if (m == 1)
                num++;
        }
    }

    cout << num << endl;
    return 0;
}

Measured memory_bytes: 3100
#include <stdio.h>

int main(void)
{
	int a,b,c,p;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > b){
		p = a;
		a = b;
		b = p;
	}
	if(b > c){
		p = b;
		b = c;
		c = p;
	}
	if(a > b){
		p = a;
		a = b;
		b = p;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
K = int(input())
S = input()
MOD = 10**9 + 7


def cmb(n, r, MOD):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % MOD


N = 3*10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % MOD)
    inverse.append((-inverse[MOD % i] * (MOD//i)) % MOD)
    g2.append((g2[-1] * inverse[-1]) % MOD)

ans = 0
for i in range(len(S), len(S)+K+1):
    ans += cmb(i-1, len(S)-1, MOD)*pow(25, i-len(S), MOD) * \
        pow(26, len(S)+K-i, MOD)
    ans %= MOD
print(ans)


Measured memory_bytes: 228452
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ll long long
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using Graph = vector<vector<int>>;
 
int main(){
  int n; cin>>n;
  if(n%10 == 3) cout << "bon";
  else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) cout << "pon";
  else cout << "hon";
}

Measured memory_bytes: 3632
#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[i];
	int m;cin>>m;
	vector<int> b(m);
	for(int i=0;i<m;++i)cin>>b[i];

	vector<int> ans;
	set_union(begin(a),end(a),begin(b),end(b),inserter(ans, end(ans)));

	for(auto &&ai: ans){
		cout<<ai<<endl;
	}
  return 0;
}



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

#define MOD (1000000007)

long long powMod(long long a, long long b){
	if(b==0)return 1;
	else if(b==1)return a%MOD;

	if(b%2){
		return (a*powMod(a,b-1))%MOD;
	}else{
		long long c=(a*a)%MOD;
		return powMod(c,b/2)%MOD;
	}
}

long long Comb(int n, int r){
	long long a=1,b=1;
	for(int i=1;i<=r;i++){
		a=(a*(n+1-i))%MOD;
		b=(b*i)%MOD;
	}

	// a/bを返す
	return (a*powMod(b,MOD-2))%MOD;
}

int main(){
	long long n,a,b;	cin>>n>>a>>b;
	// 全部の通り数は、2^n -1
	// そこからnCa, nCbを引く。	(計算量的に無理じゃね)
	// a,bが小さいからフツーにやるってことかも

	long long ans=powMod(2,n)%MOD;
	--ans;

	ans-=Comb(n,a);
	ans-=Comb(n,b);

	ans%=MOD;
	while(ans<0)ans+=MOD;

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; for(auto v : V) os << v << " "; return os << "]"; }
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; for(auto s:S) os<<s<<" ";return os<<"}"; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.first << "," << P.second << ")";}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) { os << "{ "; for(auto m:M) os<<"("<<m.first<<":"<<m.second<<") "; return os<<"}"; }
#ifdef LMAO
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){ const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | "; __f(comma+1, args...); }
#else
    #define trace(...) 42
#endif
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
#define all(x) x.begin(), x.end()
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000010;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;    
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)   
/*****************start************/

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout<<fixed<<setprecision(25);cerr<<fixed<<setprecision(10);
    int n;
    cin>>n;
    vector<int> h(n);
    for(int &i: h)
        cin>>i;
    vector<int> dp(n,MOD);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        if(i+1<n)
            dp[i+1]=min(dp[i]+abs(h[i+1]-h[i]),dp[i+1]);
        if(i+2<n)
            dp[i+2]=min(dp[i]+abs(h[i+2]-h[i]),dp[i+2]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 3988
#include <iostream>
using namespace std;
char a[101][101]={};
int i,j,k,n,m;
int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	for(j=1;j<=m;j++)
	cin>>a[i][j];
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]=='#') cout<<"#";
			else{
				k=0;
				if(a[i+1][j+1]=='#') k++;
				if(a[i][j+1]=='#') k++;
				if(a[i-1][j+1]=='#') k++;
				if(a[i+1][j]=='#') k++;
				if(a[i-1][j]=='#') k++;
				if(a[i+1][j-1]=='#') k++;
				if(a[i][j-1]=='#') k++;
				if(a[i-1][j-1]=='#') k++;
				cout<<k;
			}
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from math import ceil
step = [1,2,3]
unit = 3650.
while 1:
	n = int(raw_input())
	if n == 0:
		break
	dp = [0 for i in range(n+1)]
	dp[0] = 1
	for i in range(1,n+1):
		for j in step:
			if j <= i:
				dp[i] += dp[i-j]
	print int(ceil(dp[n] / unit))

Measured memory_bytes: 4360
#include <iostream>
#include <string>
int main()
{  
  int N, M;
  std::string A[50], B[50], result = "No";
  std::cin >> N >> M;
  
  for(int i = 0; i < N; i++)
  {
    std::cin >> A[i];
  }
  
  for(int i = 0; i < M; i++)
  {
    std::cin >> B[i]; 
  }

  for(int i = 0; i <= N - M; i++)
  {
    for(int j = 0; j <= N - M; j++)
    {
      for(int k = 0; k < M; k++)
      {
        if(A[j + k].compare(i, M, B[k]) != 0)
        {
          break;
        }
        else if(k == M - 1)
        {
          result = "Yes";
        }
      }
    }
  }
  
  std::cout << result;
  return 0;
}

Measured memory_bytes: 3108
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)

	if N > M {
		N, M = M, N
	}

	if N == 1 && M == 1 {
		fmt.Println(1)
		return
	}

	if N == 1 && M == 2 {
		fmt.Println(0)
		return
	}

	if N == 1 && M > 2 {
		fmt.Println(M - 2)
		return
	}

	if N == 2 {
		fmt.Println(0)
		return
	}

	if N > 2 && M > 2 {
		fmt.Println(N*M - (2*(N+M) - 4))
		return
	}

}


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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


string cad;
char s[N];

int memoA[N];
int memoB[N];

int B(int i){
	int &m = memoB[i];
	if(m != -1)
		return m;
	if(i == 0)
		return 0;
	if(s[i] == '.'){
		m = B(i-1);
		return m;
	}
	else{
		m = B(i-1) + 1;
		return m;
	}
}

int A(int i){
	int &m = memoA[i];
	if(m != -1)
		return m;
	if(i == 0)
		return inf;
	if(s[i] == '.'){
		m = min(A(i-1),B(i-1)) + 1;;
		return  m;
	}
	else{
		m = min(A(i-1),B(i-1));
		return m;
	}
}


int vx[100];
int vy[100];
int dp[100];
int T(int n){
	if (n == 0)
		return 0;
	int x = T(n-1);
	return max(x+vx[n]-vy[n], x);
}

int solve(int n){
	dp[0] =0;
	rep(i,1,n){
		dp[i] = max(dp[i-1] + vx[i] - vy[i], dp[i-1]);
		
	}
	return dp[n];
}

int main(void) 
{	
	
	int n; cin>> n;
	rep(i,1,n){
		cin>>vx[i];
	}
	rep(i,1,n){
		cin>>vy[i];
	}
	//cout<<T(n)<<endl;
	cout<<solve(n);
	return 0;
} 



Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int H, W;
  while (cin >> H >> W) {
    const int N = 10;
    vector<vector<ll>> c(N, vector<ll>(N));
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cin >> c[i][j];
      }
    }
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
        }
      }
    }
    ll res = 0;
    for (int i = 0; i < H * W; i++) {
      int A;
      cin >> A;
      if (A != -1) {
        res += c[A][1];
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long n,count=0,left,right;
  char c[200001],tmp;
  
  scanf("%ld",&n);
  left=0; right=n-1;
  
  scanf("%s",c);
  
  while(left<=right){
    if(c[left]=='W' && c[right]=='R'){
      tmp=c[left];
      c[left]=c[right];
      c[right]=tmp;
      left++;
      right--;
      count++;
    } else if(c[left]=='R' && c[right]=='R'){
      left++;
    } else if(c[left]=='W' && c[right]=='W'){
      right--;
    } else if(c[left]=='R' && c[right]=='W'){
      left++;
      right--;
    }
  }
  printf("%ld",count);
}

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

int longest_path[100005];
map<int,vector<int>>graph;
int dfs(int v)
{
    if(longest_path[v] != -1)
    {
        return longest_path[v] ;
    }

    int longest_child_path = 0;

    for(int i = 0; i < graph[v].size(); i++)
    {
        int child = graph[v][i];

        longest_child_path = max(longest_child_path, dfs(child));
    }

    longest_path[v] = 1 + longest_child_path;

    return longest_path[v] ;
}

int main()
{
    int no_of_vertices, no_of_edges;
    cin >> no_of_vertices >> no_of_edges;

    for(int i = 1; i <= no_of_edges; i++)
    {
        int x, y;
        cin >> x >> y;

        graph[x].push_back(y);
    }

    memset(longest_path, -1, sizeof(longest_path));

    int vertices_on_longest_path = 0;

    for(int i = 1; i <= no_of_vertices; i++)
        vertices_on_longest_path = max(vertices_on_longest_path, dfs(i));

   
    int edges_on_longest_path = vertices_on_longest_path - 1;

    cout << edges_on_longest_path;

    return 0;
}

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

int main(){
    string s; cin >> s;
    string st, fi = "";
    string make;
    string c = "keyence";
    for(int i = 0; i < s.size(); i++){
        for(int l = 1; l <= 7 && i+l < s.size(); l++){
            st = s.substr(i, l);
            for(int m = i+l; m < s.size(); m++){
                if(i == 0){
                    fi = s.substr(m, 7-l);
                    make = st + fi;
                    if(make == c){
                        if(m == i+l){
                            cout << "YES" << endl;
                            return 0;
                            return 0;
                        }else{
                            if(m + 7 - l == s.size()){
                                cout << "YES" << endl;
                                return 0;
                            }
                        }
                    }
                }else{
                    fi = s.substr(i+l, 7-l);
                    make = st + fi;
                    if(make == c && i+7 == s.size()){
                        cout << "YES" << endl;
                        return 0;
                    }
                }
                fi = "";
            }
            st = "";
        }
    }
    cout << "NO" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

//#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}

int n, k, r, s, p,tot;
string t;

int main() {
	cin >> n >> k >> r >> s >> p >> t;
	rep(i, n) {
		if (i - k >= 0 && t[i] == t[i - k]) {
			t[i] = ' ';
			continue;
		}
		if (t[i] == 'r') {
			tot += p;
		}
		else if (t[i] == 's') {
			tot += r;
		}
		else if (t[i] == 'p') {
			tot += s;
		}
	}
	cout << tot << endl;
}


Measured memory_bytes: 3760
import sys
readline = sys.stdin.readline


def main():
    N = int(readline())  # 偶数
    A = list(map(int, readline().rstrip().split()))  # [自分以外の全ての整数のxor, ...]
    
    if N == 2:
        print(*A[::-1])
        return
    
    xor = []
    for i in range(N-1):
        xor.append(A[i] ^ A[i+1])  # a xor b, b xor c, c xor d ...
    
    # bを求める
    b = A[0]
    for i in range(2, N, 2):
        b ^= xor[i]
    
    # aを求める
    a = xor[0] ^ b

    # print(a, b)
    res = [a, b]
    pre = b

    # c以降を求める
    for x in xor[1:]:
        next = pre ^ x
        res.append(next)
        pre = next

    
    print(*res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 36324