akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    string s;
    cin >> s;
    int ansa=0,ansb=0;
    for(int i=0;i<s.size();i++){
        if(i&1){
            if(s.at(i)=='0'){
                ansa++;
            }else{
                ansb++;
            }
        }else{
            if(s.at(i)=='0'){
                ansb++;
            }else{
                ansa++;
            }
        }
        
    }
    cout << min(ansa,ansb) << endl;
    return 0;
}

Measured memory_bytes: 3252
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N;
pi A[100000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) {
        cin >> A[i].first;
        A[i].second = i;
    }
    sort(A, A+N);
    rep(i,N) cout << A[i].second+1 << " ";
    cout << endl;
}

Measured memory_bytes: 1664
import sys
input = sys.stdin.readline
f = lambda:map(int,input().split())
n,m = f()
llm = []
lln = [[] for _ in range(n)]
ll = []
for i in range(m):
  p,y = f()
  llm.append([i,p,y])
  lln[p-1].append([y,i])
for j in range(n):
  lln[j].sort()
  for k in range(len(lln[j])):
    ll.append([lln[j][k][1],j+1,k+1])
ll.sort()
for i in range(m):
  print(str(ll[i][1]).zfill(6)+str(ll[i][2]).zfill(6))

Measured memory_bytes: 58700
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
#define MAX_V 3000
#define INF 1000000000

struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};

int main()
{
    int n; //頂点の数
    int m; //辺の数
    cin >> n >> m;
    int S=0; //始点
    int G=n-1; //終点
    int d[n]; //始点からそこまで行くのにかかるコスト
    vector<edge> edges; //移動の情報を保存する
    fill(d, d+n, INF); //すべての頂点をINFにする
    d[S] = 0; //始点を0にする
    int p;
  cin >> p;
    rep(i,m){
        struct edge add;
      int a,b,c;
      cin >> a >> b >> c;
        a--;
      b--;
      c-=p;
      c=c*-1;
      add.from=a;
      add.to=b;
      add.cost=c;
      edges.push_back(add);
    }
  int used[n];
  rep(i,n)used[i]=-1;
  used[n-1]=0;
  rep(i,n){
    rep(j,edges.size()){
      edge e=edges[j];
      if(used[e.to]==0&&used[e.from]==-1)used[e.from]=0;
    }
  }
  int use[n];
  rep(i,n)use[i]=-1;
  use[0]=0;
  rep(i,n){
    rep(j,edges.size()){
      edge e=edges[j];
      if(use[e.to]==-1&&use[e.from]==0)use[e.to]=0;
    }
  }
    rep(i,n){
      rep(j,edges.size()){

             edge e = edges[j];
             if(used[e.to]==-1||use[e.from]==-1)continue;
            if (d[e.to] > d[e.from] + e.cost) {  //移動した後のコストが小さいと、頂点のコストを更新
                d[e.to] = d[e.from] + e.cost;
                if (i == n-1) {         //頂点の数と同じ回数ループすると、負の閉路があるのでループをぬける
                    cout << -1 << endl;
                    return 0;
                } 
            }
        }
    }
  cout << max(d[n-1]*-1,0) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    string x, y;
    cin >> x >> y;
    vector<vector<long>> dp(x.size() + 1, vector<long>(y.size() + 1));
    // dp[i][j] edit distance from x[i] to y[i]
    for (int j = 0; j <= x.size(); j++) {
        dp[j][0] = j;
    }
    // cout << "hogrider" << endl;
    for (int j = 0; j <= y.size(); j++) {
        dp[0][j] = j;
    }
    // cout << "hogrider" << endl;
    for (int i = 1; i <= x.size(); i++) {
        for (int j = 1; j <= y.size(); j++) {
            int cost;
            if (x[i - 1] == y[j - 1]) {
                cost = 0;
            }
            if (x[i - 1] != y[j - 1]) {
                cost = 1;
            }
            dp[i][j] = min({dp[i][j - 1] + 1, dp[i - 1][j] + 1, dp[i - 1][j - 1] + cost});
        }
    }
    // cout << "hogrider" << endl;
    cout << dp[x.size()][y.size()] << endl;
}


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



int main() {ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long int i,j,n,m,q,x,y;
	cin>>n>>m>>q;
	int mat[n+1][n+1];
	for(int i=0;i<n+1;i++)
	  {
	  	for(int j=0;j<n+1;j++)
	  	  mat[i][j]=0;
	  }
	while(m--)
	  {
	    cin>>x>>y;
	    mat[x][y]+=1;
	    //mat[y][x]=1;
	  }
	for(i=1;i<n+1;i++)
	  {
	     for(j=1;j<n+1;j++)
	       mat[i][j]+=mat[i][j-1];
	  }
	while(q--)
	  {  cin>>x>>y;
	     long int count=0;
	     for(i=x;i<=n;i++)
	       {
	         count+=mat[i][y];
	       }
	      cout<<count<<'\n'; 
	  }
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n,k;
    cin>>n>>k;
    cout<<min(n%k,k-(n%k))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;

    vector<ll> H(N);
    rep(i, N) cin >> H[i];

    sort(all(H));
    reverse(all(H));

    ll ans = 0;
    repd(i, K, N) ans += H[i];

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

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  int a, b, x;
  cin >> a >> b >> x;
  if (a <= x && a + b - x >= 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


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

using namespace std;

#define gcd __gcd
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define mp make_pair
#define pb push_back
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define sbits(a) __builtin_popcount(a)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define nani(x) cerr << #x << " is " << x << endl;
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000
#define mod 1000000007

typedef long long ll;

const int N = 1e5 + 5;

int A[N];

int main()
{
    fast;

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    int ans = 0;

    for (int i = 0; i<(s.ln)>> 1; i++)
        ans += (s[i] != s[s.ln - i - 1]);

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, k, s;
    cin >> n >> k >> s;
    int m = 1e9;
    for(int i=0; i<k; i++) cout << s << " ";
    for(int i=k; i<n; i++) cout << (s==m ? s-1 : s+1) << " \n"[i==n-1];
}


Measured memory_bytes: 1280
#include<iostream>
#include<math.h>
#include<vector>
#include<stdio.h>
#include<string>
using namespace std;
int main(void){
   
    int a,b;
    cin>>a;
    string c;
    cin>>c;
    if(c=="+"){
        cin>>b;
        cout<<a+b<<endl;
    }else{
        cin>>b;
        cout<<a-b<<endl;
    }


    return 0;
}



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

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

  int q=N;
  int r=0;

  while (1) {
    r += q % 10;
    q =  q / 10;
    if (q==0) break;
  }

  if ((N % r)==0) {
   cout << "Yes";
  }
  else {
   cout << "No";
  }

  cout << endl;

}


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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N, M, X, Y);

  int x_max = -INF;
  rep(i, N) {
    var(int, x);
    chmax(x_max, x);
  }

  chmax(x_max, X);
  x_max += 1;

  if (x_max > Y) {
    outl("War");
    return 0;
  }

  bool War = false;
  rep(i, M) {
    var(int, y);
    if (y < x_max) War = true;
  }

  outl(War ? "War" : "No War");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> s(H + 2, vector<char>(W + 2, '.'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> s[i][j];
    }
  }
  bool res = true;
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (s[i][j] == '#' && s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.'){
        res = false;
      }
    }
  }
  cout << (res ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/search.h"

#define M 1064527

int main(){
    ll X, N;
    cin >> X >> N;
    ll p[N];
    REP(i, N){
        cin >> p[i];
    }
   
    ll d=0, ans1, ans2, s1, s2;
    if(N==0){
        cout << X << endl;
        return 0;
    }
    else{
        while(1){
            s1 = 0;
            s2 = 0;
            ans1 = X+d;
            ans2 = X-d;
            REP(i, N){
                if(ans2==p[i]) s2=1;
                if(ans1==p[i]) s1=1;
                if(s1==1 && s2==1) break;
             }
             if(s2==0){
                 cout << ans2 << endl;
                 return 0;
             }
             else if(s1==0){
                 cout << ans1 << endl;
                 return 0;
             }
             d++;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3628
N,M = map(int,input().split())
array = [0 for i in range(N+1)]
c = 0
for i in range(M):
    a = int(input())
    if array[a-1] == 0:
        array[a] = 1
    else:
        c = 1
        break
if c == 1:
    print(0)
else:
    dp = [0 for i in range(N+1)]
    dp[0] = 1
    for i in range(N-1):
        if array[i+1] == 0:
            dp[i+1] += dp[i]%(10**9+7)
        if array[i+2] == 0:
            dp[i+2] += dp[i]%(10**9+7)
    if array[N-1] == 0:
        dp[N] += dp[N-1]%(10**9+7)
    print(dp[-1]%(10**9+7))

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        string s;
        cin >> s;

        ll n = s.size();

        v<P> r_to_l(n, P(-1, -1));
        stack<ll> st;
        for (long long i = 0; i < n; ++i) {
            if (s[i] == 'R') {
                st.push(i);
            } else {
                ll d = 1;
                while (!st.empty()) {
                    ll top = st.top();
                    st.pop();
                    r_to_l[top] = P(i, d);
                    d++;
                }
            }
        }
        v<P> l_to_r(n, P(-1, -1));
        stack<ll> stt;
        for (long long i = n - 1; i >= 0; --i) {
            if (s[i] == 'L') {
                stt.push(i);
            } else {
                ll d = 1;
                while (!stt.empty()) {
                    ll top = stt.top();
                    stt.pop();
                    l_to_r[top] = P(i, d);
                    d++;
                }
            }
        }

        vl ans(n, 0);
        for (long long i = 0; i < n; i++) {
            if (s[i] == 'R') {
                ll l_idx = r_to_l[i].F;
                ll d = r_to_l[i].S;

                if (d % 2 == 0) {
                    ans[l_idx]++;
                } else {
                    ans[l_idx - 1]++;
                }
            } else {
                ll r_idx = l_to_r[i].F;
                ll d = l_to_r[i].S;

                if (d % 2 == 0) {
                    ans[r_idx]++;
                } else {
                    ans[r_idx + 1]++;
                }
            }
        }

        rep(i, n) cout << ans[i] << ' ';


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 5020
inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')[0].split(' ')
X = inp.shift() * 1
A = inp.shift() * 1
B = inp.shift() * 1
console.log(B - A > X ? 'dangerous' : B - A <= 0 ? 'delicious' : 'safe')

Measured memory_bytes: 7372
/*
#include<bits/stdc++.h>
using namespace std;
char s[N][10010];
bitset<10010>ok[2010];
int n,k;
int len[2010];
char ans[10010];
pair<int,int>p[2][20010];
int cnt,ncnt;
int main()
{
    //freopen("H:\\c++1\\in.txt","r",stdin);
    //freopen("H:\\c++1\\out.txt","w",stdout);
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%s",s[i]+1);//
        len[i]=strlen(s[i]+1);//
    }
    ok[n+1][0]=1;
    for(int i=n;i>=1;i--){
        ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
    }
    for(int i=1;i<=n;i++){
        if(ok[i+1][k-len[i]]){
            p[0][++cnt]=make_pair(i,1);//
        }
    }
    int f=0;
    for(int i=1;i<=k;i++){//
        char mi='z';
        for(int j=1;j<=cnt;j++){
            mi=min(mi,s[p[f][j].first][p[f][j].second]);
        }
        ans[i]=mi;
        //cout<<ans[i]<<endl;
        ncnt=0;
        int pp=n+1;
        for(int j=1;j<=cnt;j++){
            int id=p[f][j].first,pos=p[f][j].second;
            if(mi!=s[id][pos])continue;
            if(pos==len[id])pp=min(pp,id);//
            else p[f^1][++ncnt]=make_pair(id,pos+1);
        }
        for(int j=pp+1;j<=n;j++){
            if(k>=i+len[j]&&ok[j+1][k-i-len[j]])p[f^1][++ncnt]=make_pair(j,1);//
        }
        f^=1;
        cnt=ncnt;
    }
    printf("%s\n",ans+1);//
    return 0;
}
*/
#include<bits/stdc++.h>
using namespace std;
bitset<10010> ok[2010];
pair<int,int> p[2][10010];
char s[2010][10010],ans[1000010];
int len[2010],n,k,cnt=0,ncnt=0;
int main()
{
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++) scanf("%s",s[i]+1),len[i]=strlen(s[i]+1);
    ok[n+1][0]=1;
    for (int i=n;i>=1;i--)
        ok[i]=ok[i+1]|(ok[i+1]<<len[i]);
    for (int i=1;i<=n;i++)
        if (ok[i+1][k-len[i]]) p[0][++cnt]=make_pair(i,1);
    int f=0;
    for (int i=1;i<=k;i++)
    {
        char mi='z';
        for (int j=1;j<=cnt;j++) mi=min(mi,s[p[f][j].first][p[f][j].second]);
        ans[i]=mi;
        int mx=n+1;
        ncnt=0;
        for (int j=1;j<=cnt;j++)
        {
            int id=p[f][j].first,pos=p[f][j].second;
            if (s[id][pos]!=mi) continue;
            if (pos==len[id]) mx=min(mx,id);
            else p[f^1][++ncnt]=make_pair(id,pos+1);
        }
        for (int j=mx+1;j<=n;j++)
            if (k-len[j]-i>=0&&ok[j+1][k-len[j]-i]) p[f^1][++ncnt]=make_pair(j,1);
        f^=1;
        cnt=ncnt;
    }
    printf("%s\n",ans+1);
}

Measured memory_bytes: 22016
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)

# print(X_sort)

middle_left = X_sort[N//2-1]
middle_right = X_sort[N//2]
# print(middle_left, middle_right)

for idx, x in enumerate(X):
    if x <= middle_left:
        print(middle_right)
    elif middle_right <= x:
        print(middle_left)

Measured memory_bytes: 93780
import numpy as np

A,B,H,M = map(int,input().split())

h_theta = np.pi *(H+M/60) /6
m_theta = np.pi * M/30

h = np.array([A*np.cos(h_theta), A*np.sin(h_theta)])
m = np.array([B*np.cos(m_theta), B*np.sin(m_theta)])

ans = np.linalg.norm(h-m)

print(ans)

Measured memory_bytes: 27204
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <climits>
#include <map>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <bits/stdc++.h>

using namespace std;


const int INF=1e9 + 5;
int main(){
	cin.tie(0);
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	vector<int>dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j:{i+1,i+2}){
			if(j<n){
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	printf("%d",dp[n-1]);
	return 0;
}


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

int main(void){
  long long H;
  int N;
  cin >> H >> N;
  int sum = 0;
  int temp;
  for(int i = 0; i < N; i++){
   cin >> temp;
    sum += temp;
  }
  if(sum >= H) cout << "Yes";
  else cout << "No";
 return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll x, y;
    cin >> x >> y;
    if(x == y)cout << 0 << endl;
    else if(x == -y)cout << 1 << endl;
    else if(abs(x) < abs(y)){
        ll ans = abs(y) - abs(x);
        if(x < 0 && y < 0)ans += 2;
        else if(x < 0 || y < 0)ans++;
        cout << ans << endl;
    }else{
        ll ans = abs(x) - abs(y);
        if(x > 0 && y > 0)ans += 2;
        else if(x > 0 || y > 0)ans++;
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
mt19937 ran(time(nullptr));
inline int get_mod(int x){
	return x<mod?x:x-mod;
}
struct Hasher{
	int v,v2,v3,v4;
	Hasher(int _v=0,int _v2=0,int _v3=0,int _v4=0):v(_v),v2(_v2),v3(_v3),v4(_v4){}
	inline Hasher operator+(const Hasher& rhs) const{
		return Hasher(get_mod(v+rhs.v),get_mod(v2+rhs.v2),get_mod(v3+rhs.v3),get_mod(v4+rhs.v4));
	}
	inline Hasher operator-(const Hasher& rhs) const{
		return Hasher(get_mod(v+mod-rhs.v),get_mod(v2+mod-rhs.v2),get_mod(v3+mod-rhs.v3),get_mod(v4+mod-rhs.v4));
	}
	inline Hasher operator*(const Hasher& rhs) const{
		return Hasher((ll)v*rhs.v%mod,(ll)v2*rhs.v2%mod,(ll)v3*rhs.v3%mod,(ll)v4*rhs.v4%mod);
	}
	inline bool operator<(const Hasher& rhs) const{
		return v!=rhs.v?v<rhs.v:(v2!=rhs.v2?v2<rhs.v2:(v3!=rhs.v3?v3<rhs.v3:v4<rhs.v4));
	}
	inline bool operator==(const Hasher& rhs) const{
		return v==rhs.v && v2==rhs.v2 && v3==rhs.v3 && v4==rhs.v4;
	}
} mul_pow[500010],inv_pow[500010],mul=Hasher(ran()%mod,ran()%mod,ran()%mod,ran()%mod),hash_v[250010];
map<Hasher,int> dic;
char str[250010];
inline Hasher qpow(Hasher base,int pw){
	Hasher res=Hasher(1,1);
	while(pw){
		if(pw&1) res=res*base;
		base=base*base;
		pw>>=1;
	}
	return res;
}
int main(){
	int n;
	scanf("%d%s",&n,str+1);
	mul_pow[0]=Hasher(1,1);
	inv_pow[0]=Hasher(1,1);
	Hasher mul_inv=qpow(mul,mod-2);
	for(int i=1;i<=2*n;i++){
		mul_pow[i]=mul_pow[i-1]*mul;
		inv_pow[i]=inv_pow[i-1]*mul_inv;
	}
	int pos=n;
	ll ans=0;
	for(int i=1;i<=n;i++){
		if(str[i]=='+'){
			hash_v[i]=hash_v[i-1]+mul_pow[pos];
		}else if(str[i]=='-'){
			hash_v[i]=hash_v[i-1]-mul_pow[pos];
		}else if(str[i]=='>'){
			pos++;
			hash_v[i]=hash_v[i-1];
		}else if(str[i]=='<'){
			pos--;
			hash_v[i]=hash_v[i-1];
		}
	}
	pos=n;
	for(int i=1;i<=n;i++){
		if(hash_v[i]==hash_v[n]) ans++;
		if(str[i]=='>') pos++;
		else if(str[i]=='<') pos--;
		ans+=dic[hash_v[i]];
		if(pos<n)
			dic[hash_v[n]*inv_pow[n-pos]+hash_v[i]]++;
		else
			dic[hash_v[n]*mul_pow[pos-n]+hash_v[i]]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 51328
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 200;

char G[maxn][maxn];
int col[maxn], row[maxn];

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int n = read(), m = read();
	rep1(i, 1, n)
	{
		rep1(j, 1, m)
		{
			cin>>G[i][j];
			if(G[i][j] == '#')
			{	
				row[i] = 1;
				col[j] = 1;
			}
		}
	}
	rep1(i, 1, n)
	{
		if(!row[i]) continue;
		rep1(j, 1, m)
		{
			if(!col[j]) continue;
			printf("%c", G[i][j]);
		}
		printf("\n");
	}
	
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <bitset>
#include <set>

#define FOR(i, a, b) for(int i = (int)a; i < (int)b; ++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
template <class T, class U> void CHMAX(T & a, const U & b) { if (a < b) a = b; }
template <class T, class U> void CHMIN(T& a, const U& b) { if (a > b) a = b; }

constexpr int INF = (1 << 30) - 1;

using State = std::string::iterator;
struct Node {
	std::vector<Node> child;
	std::vector<char> op;
	std::vector<int> val;

	int num(State& it) {
		int res = 0;
		while (std::isdigit(*it)) {
			res = res * 10 + (*it - '0');
			++it;
		}
		return res;
	}

	void eval() {
		std::vector<int> ps(child.size(), 0);
		std::set<int> set;

		while (true) {
			auto rec = [&](auto && f, std::vector<int> v, std::vector<char> c) -> void {
				if (c.empty()) {
					set.emplace(v[0]);
					return;
				}
				REP(i, c.size()) {
					if (c[i] == '/' && v[i + 1] == 0) continue;
					auto tv(v);
					auto tc(c);
					if (tc[i] == '+') tv[i] += tv[i + 1];
					if (tc[i] == '-') tv[i] -= tv[i + 1];
					if (tc[i] == '*') tv[i] *= tv[i + 1];
					if (tc[i] == '/') tv[i] /= tv[i + 1];
					tv.erase(tv.begin() + i + 1);
					tc.erase(tc.begin() + i);
					f(f, tv, tc);
				}
			};
			std::vector<int> v(child.size());
			REP(i, child.size()) v[i] = child[i].val[ps[i]];
			rec(rec, v, op);

			int p = ps.size() - 1;
			while (p >= 0) {
				++ps[p];
				if (ps[p] == child[p].val.size()) {
					ps[p] = 0;
					--p;
				}
				else {
					break;
				}
			}
			if (p < 0) break;
		}
		val.reserve(set.size());
		for (auto& x : set) val.emplace_back(x);
	}

	Node(int n) {
		val.emplace_back(n);
	}
	Node(State& it) {
		while (*it != '$' && *it != ')') {
			if (*it == '(') {
				++it;
				child.emplace_back(it);
			}
			else if (std::isdigit(*it)) {
				child.emplace_back(num(it));
			}
			else {
				op.emplace_back(*it);
				++it;
			}
		}
		++it;

		eval();
	}
};

signed main() {

	std::string s;
	while (std::cin >> s, s != "#") {
		s += '$';
		auto it = s.begin();
		Node r(it);
		std::cout << r.val.size() << std::endl;
	}

	return 0;
}


Measured memory_bytes: 3176
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <assert.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(s) (s).begin(),(s).end()
#define ITE(c) typeof((c).begin())

#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizeof(a))
#define pb push_back
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define MP(a,b) make_pair((a),(b))

#define INF 1<<24
#define MAX_V 999

using namespace std;

int dat[10][10];

int main(){
	int a, b, c, num;
	int n;
	while(cin>>n,n){
		num=0;
		rep(i,10){
			rep(j,10){
				if(i==j){
					dat[i][j]=0;
				}else{
					dat[i][j]=INF;
				}
			}
		}
		rep(i,n){
			cin>>a>>b>>c;
			dat[a][b]=c;dat[b][a]=c;
			num=max(num,max(a,b));
		}
		num++;
		rep(i,num){
			rep(j,num){
				rep(k,num){
					dat[j][k]=min(dat[j][k],dat[j][i]+dat[i][k]);
				}
			}
		}
		
		
		int sum, mC=INF,id;
		rep(i,num){
			sum=0;
			rep(j,num){
				sum+=dat[i][j];
			}
			if(sum<mC){
				mC=sum;id=i;
			}
		}
		cout<<id<<" "<<mC<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#C
N,M = map(int,input().split())
PS = [list(input().split()) for i in range(M)]

f = [0]*N
pena = [0]*N
for ps in PS:
    p,s = ps
    p = int(p)
    s = str(s)
    if f[p-1] == 0:
        if s == "AC":
            f[p-1] = 1
        else:
            pena[p-1]+=1
pe = 0        
for i in range(N):
    if f[i] == 1:
        pe+=pena[i]
print(sum(f),pe)
        
    



Measured memory_bytes: 27444
str = input()

list = []
num = []

for i in str:

    if len(list) is 0:
        list.append(i)
    else:
        if list.count(i) == 0:
                list.append(i)



for i in list:
    num.append(str.count(i))

if len(num) is 2 and num[0]==2 and num[1]==2:
    print("Yes")
else:
    print("No")
    

    








Measured memory_bytes: 3060
N = int(input())
N_half = N//2

min_sum = N

for A in range(1,N_half+1):
  digit_a = 0
  digit_b = 0
  B = N-A
  while A!=0:
    num = A%10
    digit_a += num
    A = A//10
  while B!=0:
    num = B%10
    digit_b += num
    B = B//10
  digit = digit_a + digit_b
  if digit<min_sum:
    min_sum = digit

print(min_sum)

Measured memory_bytes: 9192
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll n, a, b;
	cin>>n>>a>>b;
	if((b-a)%2==0) cout<<(b-a)/2<<endl;
	else cout<<min({a+(b-a-1)/2, n-b+1+(b-a-1)/2})<<endl;
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  sort(p.begin(), p.end());
  int sum = 0;
  rep(i, k) sum += p[i];
  cout << sum << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
int a,b,c,d,e,f,g,p;
string s,s1,s2,s3,s4,s5;
int main(){
  cin >> a >> p;
  cout << (((a*3)+p) / 2) << endl;
}


Measured memory_bytes: 764
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun main() {
    val (n, k) = intList()
    val d = intList()
    val numbers = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9) - d
    val patterns = mutableListOf<Int>()
    fun gen(digits: Int, numbers: List<Int>, s: String) {
        if(s.isNotEmpty()) {
            patterns.add(s.toInt())
        }
        if (digits > 0) {
            numbers.forEach {
                gen(digits - 1, numbers, s + it)
            }
        }
    }
    gen(n.toString().length + 1, numbers, "")
    val min = patterns.filter { it >= n }.min()
    println(min.toString())
}


Measured memory_bytes: 52328
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <complex>
 
using namespace std;
 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
int gcd(int a, int b)
{
	while (b != 0) {
		int t = b;
		b = a % b;
		a = t;
	}
	return a;
}
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	int MAXN = 1000100, n, i, j, k, g, ct;
	bool pairwise, setwise;
 
	cin >> n;
	vector<int> a(n);
	vector<int> used(MAXN, 0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) g = a[i];
		else g = gcd(g, a[i]);
		used[a[i]]++;
	}
 
	pairwise = true;
	for (i = 2; i < MAXN; i++) {
		ct = 0;
		for (j = i; j < MAXN; j += i) ct += used[j];
		if (ct > 1) pairwise = false;
	}
 
	if (pairwise) cout << "pairwise coprime\n";
	else if (g == 1) cout << "setwise coprime\n";
	else cout << "not coprime\n";
 
 
	return 0;
}
///from wiji

Measured memory_bytes: 11112
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Iterator;
import java.util.LinkedList;

public class Main {
	public static void main(String[] args) {

		// LinkedList型としてインスタンス化
		LinkedList<Integer> list = new LinkedList<>();

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
			int n = Integer.parseInt(br.readLine());
			for (int i = 0; i < n; i++) {
				String[] cmd = br.readLine().split(" ");
				switch (cmd[0]) {
				case "insert":
					// リストの先頭に追加
					list.addFirst(Integer.parseInt(cmd[1]));
					break;

				case "delete":
					// parseIntの戻り値はint型である為、
					// そのまま渡すとremove(int index)が呼び出されてしまう。
					// 明示的にInteger型に変換することで、
					// remove(Object o)メソッドを呼び出す。
					list.remove((Integer) Integer.parseInt(cmd[1]));
					break;

				case "deleteFirst":
					// 先頭の要素を削除
					list.removeFirst();
					break;

				case "deleteLast":
					// 末尾の要素を削除
					list.removeLast();
					break;
				}
			}

			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
			for (Iterator<Integer> it = list.listIterator(); it.hasNext();) {
				bw.write(it.next().toString());
				if (it.hasNext()) {
					bw.write(" ");
				} else {
					bw.write(System.lineSeparator());
				}
			}
			bw.flush();

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}


Measured memory_bytes: 204196
#include<stdio.h>
int main(void){
 int i,a,b;
   scanf("%d",&i);
  scanf("%d %d",&a,&b);
  if(b-a>=i){puts("OK");}
  else if(b-b%i>=a){ puts("OK");}
  else {puts("NG");}
  return 0; 
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF 1000000000000000000
#define pi atan(1)*4
#define MOD 1000000000+7L
#define eps 0.0000006
#define MAX_V 10000
 
using namespace std;
 
int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}
	int sum = 0;
	for (int i = 0; i < n; ++i){
		for (int j = i+1; j < n; ++j){
			sum += a[i]*a[j];
		}
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;cin>>n;
	string s1,s2;
	int k1,k2;k1=k2=0;
	while(n--){
		cin>>s1>>s2;
		if(s1>s2)k1+=3;
		else if(s1<s2)k2+=3;
		else k1+=1,k2+=1;
	}
	cout<<k1<<' '<<k2<<endl;
	return 0;
}


Measured memory_bytes: 3204
a,b,c,d,e,k = int(input()),int(input()),int(input()),int(input()),int(input()),int(input())
antennas = [a,b,c,d,e]
def a(antennas, k):
  if k == 0:
    print("Yay!")
    return
  for i in range(4):
    for j in range(i,5):
      if abs(antennas[i]-antennas[j]) > k:
        print(":(")
        return
  print("Yay!")
  return
a(antennas, k)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e3 + 10;
int a[2][N][N];
int sum[2][N][N];

int query(int k, int x1, int y1, int x2, int y2) {
  auto a = sum[k];
  return a[x2][y2] - a[x1][y2] - a[x2][y1] + a[x1][y1];
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    int x, y;
    static char s[10];
    scanf("%d%d%s", &x, &y, s);
    int d = x / m + y / m;
    x %= m;
    y %= m;
    int z = s[0] == 'W' ? 0 : 1;
    if (d % 2) z = 1 - z;
    a[z][x][y]++;
  }
  for (int k = 0; k < 2; ++k) {
    for (int i = 1; i <= m; ++i) {
      for (int j = 1; j <= m; ++j) {
        sum[k][i][j] = sum[k][i - 1][j] + sum[k][i][j - 1] -
          sum[k][i - 1][j - 1] + a[k][i - 1][j - 1];
      }
    }
  }
  int ret = 0;
  for (int u = 0; u <= m; ++u) {
    for (int v = 0; v <= m; ++v) {
      int cur = query(0, 0, 0, u, v) + query(0, u, v, m, m) +
        query(1, 0, v, u, m) + query(1, u, 0, m, v);
      ret = max(ret, cur);
      cur = query(1, 0, 0, u, v) + query(1, u, v, m, m) +
        query(0, 0, v, u, m) + query(0, u, 0, m, v);
      ret = max(ret, cur);
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 16128
#include <iostream>

int main() {
  long n, m;

  std::cin >> n;
  std::cin >> m;

  long ans=0;

  if (n==1) {
    if (m==1) {
      ans = 1;
    } else {
      ans = m - 2;
    }
  } else if (m==1) {
    ans = n - 2;
  } else {
    ans = (n-2) * (m-2);
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
/*atcoder 163 begin*/
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] arr = new int[n];
		for(int i = 0;i < n - 1;i++){
			arr[in.nextInt() - 1]++;
		}

		for(int i =0;i < n;i++){
			System.out.println(arr[i]);
		}
	}
}

Measured memory_bytes: 61596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int d;
    cin >> d;
    vector<ll> decrease(26);
    for(int i = 0; i < 26; i++) cin >> decrease[i];
    vector<vector<ll>> increase(d, vector<ll>(26));
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++){
            cin >> increase[i][j];
        }
    }
    vector<ll> contest(d);
    for(int i = 0; i < d; i++) cin >> contest[i];
    vector<ll> lastdate(26);
    ll score = 0;
    for(int i = 0; i < d; i++){
        ll realdate = i + 1;
        lastdate[contest[i] - 1] = realdate;
        score += increase[i][contest[i] - 1];
        for(int j = 0; j < 26; j++){
            score -= (realdate - lastdate[j]) * decrease[j];
        }
        cout << score << "\n";
    }
    //cout << "hello";
}

Measured memory_bytes: 3724
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << endl;
    if(N-A-B >= 0) cout << 0 << endl;
    else cout << A+B-N << endl;

    return 0;
}*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    int ans = 0;
    for(int i=0; i<N; i++){
        if(A[i] == B[i] && A[i] != C[i]) ans++;
        if(A[i] == C[i] && A[i] != B[i]) ans++;
        if(B[i] == C[i] && A[i] != B[i]) ans++;
        if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) ans += 2;
        //cout << ans << " " << i << endl;
    }
    cout << ans << endl;
    
    return 0;
}


/*

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

/*

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

/*

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

/*

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

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

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

	vector<int> a(n);
	bool f_zero = false;
	int num_m = 0;
	long long s = 0;
	int m = 1e9;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]==0) f_zero = true;
		if(a[i]<0) num_m++;
		s += abs(a[i]);
		m = min(m,abs(a[i]));
	}

	if(f_zero || num_m%2==0) cout << s << endl;
	else cout << s-2*m << endl;
}

Measured memory_bytes: 3796
n, l = map(int, input().split())
aji = [l + i for i in range(n)]
Sum = sum(aji)
# print(Sum)
dif = float('inf')
# print(aji)
for a in aji:
    SSum = Sum - a
    # print(SSum, Sum, dif,  Sum - SSum)
    if abs(Sum - SSum) < dif:
        dif = abs(Sum - SSum)
        ans = SSum
    
print(ans)
# abs_aji = []
# for a in aji:
#     abs_aji.append(abs(a))
# abs_aji.sort()
# print(abs_aji)
# print(aji)

# ans = sum(aji)
# if abs_aji[0] < 0:
#     ans += abs_aji[0]
# else:
#     ans -= abs_aji[0]
# print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	int32_t n, m, x;
	cin >> n >> m >> x;

	uint32_t left = 0, right = 0;
	int32_t temp;
	for (int32_t i = 0; i < m; i++) {
		cin >> temp;
		if (temp > x) {
			right++;
		}
		else {
			left++;
		}
	}
	printf("%d\n", min(left, right));
	return 0;
	//	std::cout << "Hello World!\n"; 
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        q : [(i32,i32);m],
    }

    let mut l: Vec<i32> = vec![];
    let mut r: Vec<i32> = vec![];

    for e in q {
        l.push(e.0);
        r.push(e.1);
    }

    let l_max = l.iter().max().unwrap();
    let r_min = r.iter().min().unwrap();
    let ans = max(0, r_min - l_max + 1);


    println!("{}", ans);

}


Measured memory_bytes: 4864