akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int h, w, k; cin >> h >> w >> k;
  vector<vector<bool>> grid(h, vector<bool>(w, false));
  P s = {-1, -1};
  for(int i=0;i<h;++i) {
    for(int j=0;j<w;++j) {
      char tmp; cin >> tmp;
      if(tmp == 'S') {
        s = {i, j};
      } else if(tmp == '#') {
        grid[i][j] = true;
      }
    }
  }
  vector<int> dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
  vvi dist(h, vi(w, INF));
  queue<P> que;
  que.push(s);
  grid[s.first][s.second] = true;
  dist[s.first][s.second] = 0;
  int tmp1 = (s.first - 1) / k + 2;
  int tmp2 = (s.second - 1) / k + 2;
  int tmp3 = ((h - 1 - s.first) - 1) / k + 2;
  int tmp4 = ((w - 1 - s.second) - 1) / k + 2;
  int mi = min(tmp1, min(tmp2, min(tmp3, tmp4)));
  while(!que.empty()) {
    int nowf = que.front().first, nows = que.front().second; que.pop();
    for(int i=0;i<4;++i) {
      int nxtf = nowf + dx[i], nxts = nows + dy[i];
      if(nxtf < 0 || h <= nxtf || nxts < 0 || w <= nxts) continue;
      if(!grid[nxtf][nxts]) {
        grid[nxtf][nxts] = true;
        dist[nxtf][nxts] = dist[nowf][nows] + 1;
        if(dist[nxtf][nxts] <= k) {
          if(nxtf == 0 || nxtf == h-1 || nxts == 0 || nxts == w-1) {
            cout << 1 << endl;
            return 0;
          }
          tmp1 = (nxtf - 1) / k + 2;
          tmp2 = (nxts - 1) / k + 2;
          tmp3 = ((h - 1 - nxtf) - 1) / k + 2;
          tmp4 = ((w - 1 - nxts) - 1) / k + 2;
          mi = min(mi, min(tmp1, min(tmp2, min(tmp3, tmp4))));
        }
        que.push({nxtf, nxts});
      }
    }
  }
  cout << mi << endl;
}


Measured memory_bytes: 2944
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n,k;cin>>n>>k;

  int M = n*(n-1)/2 - (n-1);
  dump(M);
  if (k>M) {
    cout << -1 << endl;
    return 0;
  }

  vvi d(n, vi(n, 0));
  rep(i, n){
    rep(j, n){
      if (i>=j) continue;
      if (i==0) {
        d[i][j]=1;
        d[j][i]=1;
      }
    }
  }
  dump_2d(d, n, n);

  rep(i, n){
    rep(j, n){
      if (k==M){
        dump_2d(d, n, n);
        int m = 0;
        vector<pii> res;
        rep(i, n){
          rep(j, n){
            if (i>=j) continue;
            m += d[i][j];
            if (d[i][j]) res.pb(mp(i, j));
          }
        }
        dump(m);
        dump(res);
        cout << m << endl;
        rep(i, m){
          int x,y;
          tie(x,y) = res[i];
          cout << x+1 << " " << y+1 << endl;
        }
        return 0;
      }

      if (i>=j) continue;
      if (i==0) continue;
      if (d[i][j]==0) {
        d[i][j]=1;
        d[j][i]=1;
        M--;
      }
    }
  }


  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
using namespace std;

static const int mod = 1e9 + 7;

int fast_power(int a, int b) {
  long long p = 1, q = a;
  while (b) {
    if (b & 1) p = p * q % mod;
    q = q * q % mod;
    b >>= 1;
  }
  return p;
}

int main() {
  int k;
  scanf("%d", &k);
  string s;
  cin >> s;

  int n = s.length() + k;
  vector<int> g(n + 1, 1);
  for (int i = 1; i <= n; i++)
    g[i] = fast_power(i, mod - 2);

  long long c = 1;
  long long ans = fast_power(26, k);
  for (int i = 0; i < k; i++) {
    c = c * (static_cast<long long>(s.length()) + i) % mod * g[i + 1] % mod;
    ans = (ans + c * fast_power(25, i + 1) % mod * fast_power(26, k - i - 1) % mod) % mod;
  }

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

  return 0;
}

Measured memory_bytes: 12176
n = int(input())
a = [True] * n
m = [[-1] * n for i in range(n)]
for i in range(n):
    n2 = int(input())
    for j in range(n2):
        x,y = map(int,input().split())
        m[i][x-1] = y

cnt = 0
for i in range(2**n):
    x = i
    for j in range(n):
        a[j] = x % 2
        x = x // 2

    for j in range(n):
        for k in range(j,n):
            if a[j] == 1 and a[k] == 1:
                if m[j][k] == 0 or m[k][j] == 0:
                    break
            elif a[j] == 1 and a[k] == 0:
                if m[j][k] == 1:
                    break
            elif a[j] == 0 and a[k] == 1:
                if m[k][j] == 1:
                    break
        else:
            continue
        break
    else:
        if a.count(1) > cnt:
            cnt = a.count(1)
print (cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  
  int ta=0, tb=0;
  for(char c : s){
    if(c == 'a'){
      if(ta+tb < a+b){
	cout << "Yes" << endl;
	ta++;
      }else{
	cout << "No" << endl;
      }
    }else if(c == 'b'){
      if(ta+tb < a+b and tb<b){
	cout << "Yes" << endl;
	tb++;
      }else{
	cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  } 
}


Measured memory_bytes: 896
/*
g++ -std=c++11 -o2 -Wall ABC097D.cpp -o ./out/ABC097D.out
./out/ABC097D.out
*/

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

typedef long long ll;

class Union_Find{
private:
    vector<int> par, rank;

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
public:
    Union_Find(int Max_Node){
        par.resize(Max_Node);
        rank.resize(Max_Node);
    }

    void init(int n) {
        for(int i = 0; i < n; i++){
            par[i] = i;
            rank[i] = 0;
        }
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y)return ;

        if(rank[x] < rank[y]){
            par[x] = y;
        }else{
            par[y] = x;
            if(rank[x] == rank[y])rank[x]++;
        }
    }

    bool same(int x, int y){
        return (find(x) == find(y));
    }
};

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> in(n);
    for(int i = 0; i < n; i++)cin >> in[i];
    Union_Find uf(n + 1);
    uf.init(n + 1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
//        uf.unite(b, a);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(uf.same(in[i], i+1)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
    int a;
    int b;
    char op;
    while(true){
        cin >> a>> op >> b;
        if(op == '+'){
            cout << a+b << endl;
        }
        if(op == '-'){
            cout << a-b << endl;
        }
        if(op == '*'){
            cout << a*b << endl;
        }
        if(op == '/'){
            cout << a/b << endl;
        }
        if(op == '?'){
            break;
        }
    }
}


Measured memory_bytes: 3092
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <math.h>

int main(void){
    using namespace std;
    long long a;

    cin >> a;

    long long a_l[a];
    long long b_l[a];

    int right = 0;
    int left = 0;

    long long mean = 0;

    long long sum = 0;
    long long num = 0;

    for(long long i=0; i < a; i++){
        cin >> a_l[i];
        sum += a_l[i]; 
    }

    long long l_sum = a_l[0]+a_l[1];
    long long r_sum = sum-l_sum;

    long long l_comp = a_l[0];
    long long r_comp = a_l[2];

    long long l_l[a];
    long long r_l[a];

    long long l_n = 0;
    long long r_n = 2;

    long long min_n = pow(10, 10);

    //cout << l_sum << ' ' << l_comp << ' ' << r_sum << ' ' << r_comp << endl;

    for(long long i=1; i < a-2; i++){
        //cout << min_n << endl;
        while ((((l_sum-l_comp)-l_comp) > a_l[l_n+1]) && (i-1 > l_n)){
            l_comp += a_l[l_n+1];
            l_n += 1;
        }
        while ((((r_sum-r_comp)-r_comp) > a_l[r_n+1]) && (a-1 > r_n)){
            r_comp += a_l[r_n+1];
            r_n += 1;
        }
        //cout << a_l[r_n+1] << ' ' << r_n << endl;
        l_l[i] = l_n;
        r_l[i] = r_n;
        
        

        long long min_k = min({l_comp, l_sum-l_comp, r_comp, r_sum-r_comp});
        long long max_k = max({l_comp, l_sum-l_comp, r_comp, r_sum-r_comp});

        //cout << min_k << ' ' << max_k << ' ' << min_n << endl;

        if (min_n > (max_k - min_k)){
            min_n = (max_k - min_k);
        }
        //cout << l_sum << ' ' << l_comp << ' ' << r_sum << ' ' << r_comp << ' ' <<  min_n  << endl;
        l_sum += a_l[i+1];
        r_sum -= a_l[i+1];
        r_comp -= a_l[i+1];
        if (r_comp == 0){
            r_comp = a_l[i+2];
            r_n += 1;
        }
    }

    cout << min_n << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000001

int cnt;

void merge(int a[], int left, int mid, int right){
    int l[mid-left+1], r[right-mid+1];
    l[mid-left] = INF;
    r[right-mid] = INF;
    for(int i = 0; i < mid - left; i++) l[i] = a[left + i];
    for(int i = 0; i < right - mid; i++) r[i] = a[mid + i];
    int j = 0, k = 0;
    for(int i = left; i < right; i++){
        l[j] <= r[k] ? a[i] = l[j++] : a[i] = r[k++];
        cnt++;
    }
}

void mergeSort(int a[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main(){
    int n; cin >> n;
    int a[n];
    
    for(int i = 0; i < n; i++) cin >> a[i];
    
    mergeSort(a, 0, n);

    for(int i = 0; i < n; i++)
        i != n-1 ? cout << a[i] << " " : cout << a[i] << endl;
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 6908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n';


signed main(){
	int n;cin>>n;
	ll arr[n];
	ll ans = 0;
	for(int i =0 ; i < n; ++i) cin>>arr[i];
	for(int i = 1; i < n; ++i){
		ans += max(arr[i-1] - arr[i], 0LL);
		arr[i] = max(arr[i], arr[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 5180
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;

int N,K; int b[MAXN+1],c[MAXN+1]; bool vis[MAXN+1]; int sta[MAXN+1],top;
struct dat{
	int a[MAXN+1];
	inline void Pow(LL k){
		for(int i=1;i<=N;i++) vis[i]=0;
		for(int i=1;i<=N;i++){
			if(vis[i]) continue;
			int nw=i; top=0; while(!vis[a[nw]]) sta[top++]=nw=a[nw],vis[nw]=1;
			nw=k%top; for(int j=0;j<top;j++){
				b[sta[j]]=sta[nw],++nw; if(nw>=top) nw-=top; }
		} for(int i=1;i<=N;i++) a[i]=b[i];
		return ;
	}
}An[9];
dat operator * (const dat p,const dat q){
	dat nw; for(int i=1;i<=N;i++) nw.a[i]=p.a[q.a[i]]; return nw;
}
inline dat Inv(dat n){
	dat ret; for(int i=1;i<=N;i++) b[n.a[i]]=i;
	for(int i=1;i<=N;i++) ret.a[i]=b[i]; return ret;
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); K=read();
	for(int i=1;i<=N;i++) An[1].a[i]=read();
	for(int i=1;i<=N;i++) An[2].a[i]=read();
	for(int i=3;i<=7;i++) An[i]=An[i-1]*Inv(An[i-2]);
	int m=(K-1)/6,n=(K-1)%6+1;
	dat p,q; p=An[1]; q=An[2];
	dat A; A=q; A=A*Inv(p); A=A*Inv(q); A=A*p;
	dat ivA; ivA=Inv(A);
	A.Pow(m); ivA.Pow(m);
	dat ret; ret=A; ret=ret*An[n]; ret=ret*ivA;
	for(int i=1;i<=N;i++) printf("%d ",ret.a[i]);
	return 0;
}




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

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int A, B, C;
  scanf("%d%d%d", &A, &B, &C);
  int ans[3] = {A, B, C};
  sort(ans, ans + SIZE_OF_ARRAY(ans));
  printf("%d", ans[2] * 10 + ans[1] + ans[0]);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int len(int x){
	int r = 0;
	while(x) r++, x /= 10;
	return r;
}
int main(){
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	a[0]--;
	for(int i = 1; i < n; i++){
		if(a[i] - 1 >= a[i - 1]){
			a[i]--;
		}
		if(a[i] < a[i - 1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mem(s,t) memset(s,t,sizeof(s))
#define pb(s) push_back(s)
#define inf 0x3f3f3f3f
#define mn 100010
typedef long long ll;
using namespace std;

int main()
{
    int ans=0;
    int m,d,i,j;
    cin>>m>>d;
    for (i=4;i<=m;i++)
    for (j=20;j<=d;j++)
    if (j%10>=2&&((j/10)*(j%10)==i)) ans++;
    cout<<ans<<endl;
    return 0;
}



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

int main(){
    string s,t;
    cin >> s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s.at(i)==t.at(i)){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MOD1 998244353
#define MOD2 1000000007

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

int power(ll a,ll b,ll m)
{
ll ans=1;
while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;}
return ans;
}


int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    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";
    cout<<endl;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  string o, e;
  cin >> o >> e;

  int n=o.size()+e.size();
  rep(i,n){
    cout << (i&1 ? e[i/2] : o[i/2]);
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
	long long n,d,sum=0;
	cin>>n>>d;
	for(long long i=1;i<=n;i++)
	{
		long long x,y;
		cin>>x>>y;
		if(x*x+y*y<=d*d)sum++;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define elif else if
using namespace std;
int main () {
    wolfe;
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
import math
L = list(map(int,input().split()))
a = L[0]
b = L[1]
H = L[2]
M = L[3]

angleshort = 360*(60*H+M)/720
anglelong = 360*M/60

#print(angleshort)
#print(anglelong)
theta = math.radians((anglelong-angleshort))
ans = (a*a+b*b-2*a*b* math.cos(theta))**0.5
print(ans)

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<long long> lucas(100);
  lucas.at(0)=2LL;
  lucas.at(1)=1LL;
  if(N<2){
      cout << lucas.at(N) << endl;
  }
  else{
  for(int i=2; i<=N; i++){
    lucas.at(i)=lucas.at(i-1)+lucas.at(i-2);
  }
  cout << lucas.at(N) << endl;
}
}


Measured memory_bytes: 256
void main() {
	auto c = readMatrix!char(3, 3);
	foreach(i; 0..3) c[i][i].write;
	writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 200'000 + 5;

i64 T;
i64 n;

i64 l[MAXN];
i64 r[MAXN];
i64 k[MAXN];

i64 bonus(i64 i) {
    return max(l[i], r[i]) - min(l[i], r[i]);
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    cin >> T;
    for (i64 tt = 1; tt <= T; tt++) {
        cin >> n;
        for (i64 i = 1; i <= n; i++) {
            cin >> k[i] >> l[i] >> r[i];
        }

        set<pair<i64, i64>> q;
        for (i64 i = 1; i <= n; i++) {
            q.insert({ -bonus(i), i });
        }

        i64 R = 0;
        for (i64 i = 1; i <= n; i++) {
            R += min(l[i], r[i]);
        }

        set<i64> lx;
        set<i64, greater<i64>> rx;

        for (i64 i = 1; i <= n; i++) {
            lx.insert(i);
            rx.insert(i);
        }

        for (auto t : q) {
            i64 b = -t.first;
            i64 i = t.second;

            if (l[i] > r[i]) {
                auto it = lx.upper_bound(k[i]);
                if (it == lx.begin()) {
                    continue;
                }
                it--;
                lx.erase(it);
                R += b;
            }
            else {
                auto it = rx.upper_bound(k[i] + 1);
                if (it == rx.begin()) {
                    continue;
                }
                it--;
                rx.erase(it);
                R += b;
            }
        }

        cout << R << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int a = 1; a < n; a++) {
    ans += (n - 1) / a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
typedef long long ll;

int main() {
    ll n,ans=0, sum=0; cin>>n;
    ll a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
    }

    for(int i=0; i<n-1; i++){
        sum -= a[i];
        ans += (a[i]*(sum%mod))%mod;
        ans %= mod;
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 5184
MOD = int(1e9) + 7

def main():
    buf = input()
    N = int(buf)
    S = []
    for i in range(2):
        buf = input()
        S.append(buf)
    last_pattern = None # 1: 1 x 2, 2: 2 x 1
    combination = 1
    point = 0
    while point < N:
        if S[0][point] == S[1][point]: # 1 x 2
            if last_pattern is None: # first column
                combination *= 3
            elif last_pattern == 1:
                combination *= 2 # 2 possible colors
            else: # last_pattern == 2
                combination *= 1 # 1 possible color
            last_pattern = 1
            point += 1
        else: # 2 x 1
            if last_pattern is None: # first column
                combination *= 6
            elif last_pattern == 1:
                combination *= 2 # 2 possible color combinations
            else: # last_pattern == 2
                combination *= 3 # 3 possible color combinations
            last_pattern = 2
            point += 2
        combination %= MOD
    print(combination)

if __name__ == '__main__':
    main()


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

using namespace std;

int n = 0, m = 0;
int pL = 0, pR = 200000;
int L = 0, R = 0;
int result = 0;
int gg = 0;

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

    cin >> n >> m;

    for(int i=0; i<m; i++)
    {
        cin >> L >> R;
        if(L > pR || R < pL)
        {
            gg = 1;
        }
        if(L >= pL && L <= pR) pL = L;
        if(R >= pL && R <= pR) pR = R;
    }

    (gg == 1)?cout << 0:cout << pR - pL + 1;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i]=='o') ans++;
  }
  cout << 700+ans*100 << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, Q = list(map(int, sys.stdin.buffer.readline().split()))
S = sys.stdin.buffer.readline().decode().rstrip()
LR = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(Q)]


counts = [0] * N
cnt = 0
for i in range(N - 1):
    if S[i] + S[i + 1] == 'AC':
        cnt += 1
    counts[i + 1] = cnt

for l, r in LR:
    r -= 1
    l -= 1
    a = counts[r] - counts[l]
    print(a)



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

int main(){
    int a, b; cin >> a >> b;
    for (int i=1; i<=1009; i++){//消費税10%で100円(=MAX)になるのは1009円
        if (int(i*0.08)==a && int(i*0.1)==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int max = 0;
        Integer[][] energys = new Integer[n][2];
        for(int i = 0; i < n; i++) {
            energys[i][0] = sc.nextInt();
            energys[i][1] = sc.nextInt();
            max = Math.max(max, energys[i][0]);
        }
        int cnt = 0;
        Arrays.sort(energys, (e1, e2) -> e2[1] - e1[1]);
        for(Integer[] e : energys) {
            if(e[1] > max) {
                cnt++;
                h -= e[1];
            } else break;
            if(h <= 0) break;
        }
        if(h > 0) {
            cnt += (h + max - 1) / max;
        }
        System.out.println(cnt);
    }
}


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

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,i,k,j;
    cin>>n>>k;
    vector<ll> v(n);
    for(i=0;i<n;i++)
        cin>>v[i];
    
    vector<ll> dp(n,INT_MAX);
    dp[0]=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<=i+k && j<n;j++)
        {
            dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));   
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5;
int n,k;
int a[maxn+10];
int main()
{
    while(cin>>n>>k)
    {
        int index= -1;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            if(a[i]==1)
            {
                index = i;
            }
        }
        if(n<=k)
        {
            puts("1");
        }
        else
        {
            n-=k;
            int ans=1;
            ans+=ceil(n*1.0/(k-1));
            cout<<ans<<endl;
        }
    }
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  int a = s.at(0)-'0';
  int b = s.at(1)-'0';
  int c = s.at(2)-'0';
  int d = s.at(3)-'0';
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    int an=a;
    string ans = to_string(a);
    if(s.test(0)){an += b;ans += "+" + to_string(b);}
    else{an -= b;ans += "-" + to_string(b);}
    
    if(s.test(1)){an += c;ans += "+" + to_string(c);}
    else{an -= c;ans += "-" + to_string(c);}
    
    if(s.test(2)){an += d;ans += "+" + to_string(d);}
    else{an -= d;ans += "-" + to_string(d);}
    if(an==7){cout << ans + "=7" << endl;return 0;}
  }
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
int l,x,y,s = 0,d,n;
int main() {
    cin >> n;vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n - 1) {
        if (i == p[i] - 1) {
            swap(p[i], p[i + 1]); s++;
        }
    }
    if (p[n - 1] == n) s++;
    cout << s << endl;
}

Measured memory_bytes: 640
def solve():
  ar = raw_input().split(' ')
  N = int(ar[0])
  M = int(ar[1])
  sts = []
  for n in range(N) :
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    sts.append((a, b))
  cks = []
  for m in range(M) :
    ar = raw_input().split(' ')
    c = int(ar[0])
    d = int(ar[1])
    cks.append((c, d))

  for st in sts :
    #print st
    mind = float('inf')
    mini = -1
    for i in range(M):
      ckx = cks[i][0]
      cky = cks[i][1]
      d = abs(st[0] - ckx) + abs(st[1] - cky)
      #print 'd=',d
      if d < mind :
        mind = d
        mini = i
    #print 'mind=',mind, ',mini=',mini 
    print mini + 1

if __name__ == '__main__':
  solve()

Measured memory_bytes: 2696
#include <stdio.h>

int main() {
  int n, a;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      a = n / i;
      if ((1 <= i) && (i <= 9) && (1 <= a) && (a <= 9)) {
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >>c;
    if((100*a+10*b+c)%4==0){
        cout << "YES";
    }else{
        cout << "NO";
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod = 10 ** 9 + 7
n = int(input())
a = list(map(lambda x: format(int(x), "b").zfill(60), input().split()))

ans = 0
for i in range(60):
    cnt = 0
    for j in a:
        if j[- i - 1] == "1":
            cnt += 1
    tmp = cnt * (n - cnt)
    for _ in range(i):
        tmp = tmp * 2 % mod
    ans += tmp
print(ans % mod)

Measured memory_bytes: 149948
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[n];
		int n = sc.nextInt();
		int k = sc.nextInt();
		for(int i=0;k>i;i++) {
			int d = sc.nextInt();
			for(int j=0;d>j;j++) {
				int a = sc.nextInt();
				list.add(a);
			}
		}
		List<Integer> listB = new ArrayList<Integer>(new HashSet<>(list));
		System.out.println(n-listB.size());
	}
}

Measured memory_bytes: 46136
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n, m; cin >> n >> m;
    int x; cin >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i,n) {
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }
    int mx = 1e5*13;
    int ans = mx;
    for (int bit = 0; bit < (1<<n); bit++) {
        int tmp = 0;
        vector<int> k(n);
        rep(i,n) {
            if (bit & 1<<i) {
                rep(j,m) k[j] += a[i][j];
                tmp += c[i];
            }
        }

        bool flag = true;
        rep(i,m) {
            if (k[i] < x) flag = false;
        }
        if (flag) chmin(ans, tmp);
    }

    if (ans == mx) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
// ABC082_B.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h"
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string s, t;
	std::cin >> s;
	std::cin >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end()); //逆列→辞書順を最も後にしようとしている

	if (s<t)
	{
		std::cout << "Yes" << endl;
	}
	else {
		std::cout << "No" << endl;
	}


	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<climits>
#include<set>
#define ll long long
using namespace std;
int main() {
	string s;
	cin >> s;
	ll count = 0;
	for (ll i = 0; i <s.size()/2; i++) {
		if (s[i] != s[s.size() - 1 - i]) {
			count++;
			//cout << i << endl;
		}

	}
	cout << count << endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>

using namespace std;


int main()
{
    int N, S, A[100000];

    scanf("%d %d", &N, &S);
    for (int i = 0; i < N; i++) scanf("%d", &A[i]);

    int tail = 0, sum = 0, ret = 114514;
    for (int i = 0; i < N; i++) {
        while (tail < N && sum < S) {
            sum += A[tail++];
        }
        if (sum >= S) ret = min(ret, tail - i);
        sum -= A[i];
    }

    if (ret == 114514) ret = 0;
    printf("%d\n", ret);
}



Measured memory_bytes: 3140
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	int n;
	cin >> n;
	cout << n / 3 << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int N;
int order[1000][999];
int convert[1000][1000];

vector<vector<int>> E;

const int MAXV = 1005 * (1005 - 1) / 2;

int dp[MAXV];
bool finished[MAXV];
bool reached[MAXV];

int dfs(int pos) {
	if (reached[pos]) {
		if (!finished[pos])return -1;
		return dp[pos];
	}
	dp[pos] = 0;
	reached[pos] = true;
	for (int i = 0; i < E[pos].size(); i++) {
		//cout <<"pos == " << pos <<  "to " << E[pos][i] << endl;
		int res = dfs(E[pos][i]);
		if (res == -1)return -1;
		dp[pos] = max(dp[pos], res + 1);
	}
	finished[pos] = true;
	return dp[pos];
}

int main() {
	cin >> N;
	E.resize(N * (N - 1));

	int cnt1 = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (i == j)continue;
			if (j < i)convert[i][j] = convert[j][i];
			else {
				convert[i][j] = cnt1;
				cnt1++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 1; j++) {
			cin >> order[i][j], order[i][j]--;
			order[i][j] = convert[i][order[i][j]];
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N - 2; j++) {
			E[order[i][j]].push_back(order[i][j + 1]);
			//cout << order[i][j] << " -> " << order[i][j + 1] << endl;
		}
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			int res = dfs(order[i][j]);
			if (res == -1) {
				cout << -1 << endl;
				return 0;
			}
			ans = max(ans, res);
		}
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 50048
import java.io.*;

class Main {
	public static void main(String[] args) {
		BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
		try {
			int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			int len = nums.length;
			int[] A = new int[ len ];
			int i, len2 = len-1;
			
			for( i=0; i<len; i++ ) {
				A[i] = Integer.parseInt( nums[i] );
				System.out.print( i<(len2)? A[i]+" ": A[i]+"\n" );
			}
			
			int key;
			int j;
 			for( i=1; i<len; i++ ) {
				key = A[i];
				j = i - 1;
				while( 0 <= j && key < A[j] ) {
					A[ j+1 ] = A[j];
					j--;
				}
				A[ j+1 ] = key;
				for( int k=0; k<len; k++ ) {
					System.out.print( k<(len2)? A[k]+" ": A[k]+"\n" );
				}
			}

 			kb.close();
		} catch( IOException e ) {
			System.err.println( e );
		}
	}
}

Measured memory_bytes: 23796
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int Rnum = 0;
    for(int i=0; i<s.size() ; i++){
        if(s[i]=='R') Rnum++;
    }
    
    int ans=0;
    for(int i=0; i<Rnum ;i++){
        if(s[i]=='W') ans++;
    }
    cout << ans;
}


Measured memory_bytes: 3752
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}

int main() {
	char s[4];
	scanf("%s", s);
	int ans = 700;
	REP(i, 3) {
		if (s[i] == 'o')ans += 100;
	}
	PRINTD(ans);
}

Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
d = {}
s = set()
for i in l:
    s.add(i)
    if i in d:
        d[i] = d[i]+1

    else:
        d[i] = 1

som = 0
for i in s:
    x = d[i]
    if x >= 2:
        w = x*(x-1)
        w = w//2
        som = som + w

for i in l:
    x = d[i]
    if x > 2:
        f = x*(x-1)
        f = f//2
        x = x-1
        w = x*(x-1)
        w = w//2
        re = som - f + w
        print(re)
        continue

    if x == 2:
        re = som - 1
        print(re)
        continue

    print(som)

Measured memory_bytes: 95944
main=map read.words<$>getLine>>=print.(\x->mod(product x)1000000007).(\x->[fact (x!!0),fact (x!!1),if (mod((x!!0)-(x!!1))2)==0 then 2 else 1]).(\x->if (abs((x!!0)-(x!!1)))>1 then [-1,-1] else x)
 where fact x | x==0 = 1
              | x>0  = mod(x*(fact (x-1)))1000000007
              |otherwise = 0

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


#define ll long long
#define ld long double
#define ull unsigned long long
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long ,long long>
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define mod 1000000007LL
#define INF 1000000000007


 
//     long long power(long long x, long long y, long long p) 
// { 
//     long long res = 1;      
  
//     x = x % p;  
  
//     while (y > 0) 
//     { 
      
//         if (y & 1) 
//             res = (res*x) % p; 

//         y = y>>1; 
//         x = (x*x) % p; 
//     } 
//     return res; 
// } 
  

// long long modInverse(long long n, long long p) 
// { 
//     return power(n, p-2, p); 
// }  

// long long ncrp(long long n, long long r, long long p) 
// { 
   
//    if (r==0) 
//       return 1; 
  
    
//     long long fac[n+1]; 
//     fac[0] = 1; 
//     // for (long long i=1 ; i<=n; i++) 
//     //     fac[i] = fac[i-1]*i%p; 
  
//     return (fac[n]* modInverse(fac[r], p) % p * 
//             modInverse(fac[n-r], p) % p) % p; 
// }




int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


   if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }

    ll n;
    ll i;
    cin>>n;

    ll a[n];

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

    ll dp[n];
    dp[0]=0;
    dp[1]=llabs(a[1]-a[0]);

    for(i=2;i<n;i++)
    {
        dp[i]=min(llabs(a[i]-a[i-1])+dp[i-1],llabs(a[i]-a[i-2])+dp[i-2]);
    }

    cout<<dp[n-1]<<endl;


 

   return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+5;

string s;
int main()
{
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])
        cout<<"Bad";
    else cout<<"Good";
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int a[5], k;
	for(int i=0; i<5; i++){
		cin >> a[i];
	}
	cin >> k;
	for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
			if(abs(a[i])-abs(a[j])>k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<string>

using namespace std;
typedef long long LL;

const int maxn=310;

int DP[maxn][maxn][maxn],v;
char str[maxn];

int Cal()
{
    int len=strlen(str);
    memset(DP,0,sizeof(DP));
    for(int i=0;i<len;i++) DP[i][i][0]=1;
    for(int i=len-2;i>=0;i--)
        for(int j=i+1;j<len;j++)
             for(int k=0;k<=v;k++)
             {
        if(str[j]==str[i]) DP[i][j][k]=DP[i+1][j-1][k]+2;
        else
        {
            DP[i][j][k]=max(DP[i+1][j][k],DP[i][j-1][k]);
            if(k)  DP[i][j][k]=max(DP[i+1][j-1][k-1]+2,DP[i][j][k]);
        }
             }
    int ans=0;
    for(int i=0;i<=v;i++) ans=max(ans,DP[0][len-1][i]);
    return ans;
}

int main()
{
    scanf("%s",&str);
    scanf("%d",&v);
    printf("%d",Cal());
    return 0;
}


Measured memory_bytes: 116608
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define INF 1<<29
#define MAX 101010
#define MOD 100000
using namespace std;

int s[MAX],sum[MAX];

void solve(){
 int n,m,a;
 cin>>n>>m;
 FOR(i,n-1) cin>>s[i];
 int from=0,to;
 ZERO(sum);
 FOR(i,m){
  cin>>a;
  to=from+a;
  sum[max(from,to)]--;
  sum[min(from,to)]++;
  from=to;
 }
 int ans=0;
 FOR(i,n-1){
  sum[i+1]+=sum[i];
  ans=(ans+sum[i]*s[i])%MOD;
 }
 cout<<ans<<endl;
}  

int main(){
 solve();
 return 0;
}

Measured memory_bytes: 1956
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    int n;
    int f = 0;
    string s;
    cin >> n >> s;
    if(n%2 == 1) f = 1;
    rep(i,n/2){
        if(s[i] != s[i+n/2]) f = 1;
    }
    if(f == 0) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int n;
vector<int> x;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

void solve() {
    cin >> n;
    x.resize(n);
    vector<int> cx(n);
    for (int i = 0; i < n; ++i) {
        cin >> x[i];
        cx[i] = x[i];
    }
    sort(cx.begin(), cx.end());
    for (int i = 0; i < n; ++i) {
       int back = 0;
       //i番目の文字が入力値をソートした配列の(n / 2)番目未満の値であれば、入力値をソートした配列のn / 2番目が中央値
       //入力値をソートした配列の(n / 2)番目以降の値であれば入力値をソートした配列の(n / 2) - 1番目が中央値
       if (x[i] >= cx[n / 2]) {
           back = 1;
       } else {
           back = 0;
       }
       cout << cx[(n / 2) - back] << endl;
    }
    return;
}
//逆元を求める関数
long long 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;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}



Measured memory_bytes: 3712