akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); 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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vvc<ll> G(N);
    rep(i,N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    if(N==2){
        cout << "1 2" << endl;
        return 0;
    }

    queue<ll> q1, q2, q3;
    for (ll i = 1; i <= N; i += 3) q1.emplace(i);
    for (ll i = 2; i <= N; i += 3) q2.emplace(i);
    for (ll i = 3; i <= N; i += 3) q3.emplace(i);

    vl dep(N);
    queue<pair<ll,ll>> q;
    q.emplace(0,0);
    vc<bool> used(N, false);
    while(!q.empty()){
        ll now, d;
        tie(now, d) = q.front(), q.pop();
        dep[now] = d;
        used[now] = true;
        for(auto to:G[now]){
            if (used[to]) continue;
            q.emplace(to, d+1);
        }
    }

    ll cnt = 0;
    rep(i, N) if (dep[i] % 2 == 0) cnt++;
    if(min(cnt,N-cnt)<=q3.size()){
        vl ans(N);
        ll a, b;
        if (cnt < N - cnt)
            a = 0;
        else
            a = 1;

        rep(i,N){
            if(dep[i]%2==a){
                ans[i] = q3.front();
                q3.pop();
            }else{
                if(!q1.empty()){
                    ans[i] = q1.front();
                    q1.pop();
                }else if(!q2.empty()){
                    ans[i] = q2.front();
                    q2.pop();
                }else{
                    ans[i] = q3.front();
                    q3.pop();
                }
            }
        }
        rep(i, N) cout << ans[i] << " ";
        cout << endl;
        return 0;
    }

    vl ans(N);
    rep(i,N){
        if(dep[i]%2==0){
            if(!q1.empty()){
                ans[i] = q1.front();
                q1.pop();
            }else{
                ans[i] = q3.front();
                q3.pop();
            }
        }else{
            if(!q2.empty()){
                ans[i] = q2.front();
                q2.pop();
            }else{
                ans[i] = q3.front();
                q3.pop();
            }
        }
    }
    rep(i, N) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 19688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sum=0;
    int n;
    int a[1000];
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    int Min=(1<<31)-1;
//    int pos=sum%n==0?sum/n:sum/n+1;
//   cout<<pos<<endl;
    for(int j=-100; j<=100; j++)
    {
        int ans=0;
        for(int i=1; i<=n; i++)
        {
            ans+=(a[i]-j)*(a[i]-j);
        }
        Min=min(ans,Min);
    }
    cout<<Min<<endl;
    return 0;
}


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

template <class T> T min2(T a,T b){if(a<b) return a;return b;};

typedef long long ll;
ll a[200005];
int main()
{
    int n;
    cin>>n>>a[0];
    for(int i=1;i<n;i++)
    {
        scanf(" %lld",a+i);
        a[i]+=a[i-1];
    }
    ll ans=abs(2*a[0]-a[n-1]);
    for(int i=1;i<n-1;i++)
    {
        ans=min(ans,abs(2*a[i]-a[n-1]));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

typedef struct ps{
    int p;
    int s;
}A;

bool hikaku(const A &a, const A &b){
    return a.p < b.p;
}

signed main(){
    int n,m;
    cin >> n >> m;
    A q[m];
    int wa_count = 0;
    int wa_result = 0;
    int ac_result = 0;
    string buffer;

    for(int i=0;i<m;i++){
        cin >> q[i].p;
        cin >> buffer;
        if(buffer=="AC"){q[i].s = 1;}else if(buffer=="WA"){q[i].s = 0;}
    }
    stable_sort(q, q+m, hikaku);
    int nownum = 0;

    for(int i=0;i<m;i++){
        if(nownum < q[i].p){
            wa_count = 0;
            nownum = q[i].p;
        }else if(nownum > q[i].p){
            continue;
        }

        if(q[i].s == 1){
            wa_result += wa_count;
            wa_count = 0;
            ac_result++;
            nownum++;
        }else if(q[i].s == 0){
            wa_count++;
        }
    }
    cout << ac_result << " " << wa_result << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <math.h>
#include <vector>
#include <bitset>
using namespace std;
const long long INF = 1LL<<60;

bool IsPrime(int num){
        if (num < 2) return false;
        else if (num == 2) return true;
        else if (num % 2 == 0) return false;

        double sqrtNum = sqrt(num);

        for (int i = 3; i <= sqrtNum; i += 2){
                if (num % i == 0) return false;
        }

        return true;
}

int main(){

        int n;
        cin >> n;
        vector<int> l(n), r(n), sum(n);
        for (int i=0; i < n; ++i) {
                        cin >> l[i] >> r[i];
        }

        int MAX = 101010;
        vector<int> is_prime(MAX, 1);
        is_prime[0] = 0;
        is_prime[1] = 0;
        for (int i = 2; i < MAX; ++i) {
                if (!is_prime[i]) continue;
                for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
        }

        vector<int> a(MAX, 0);
        for (int i = 0; i < MAX; ++i){
                if (i % 2 == 0) continue;
                if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
        }

        vector<int> s(MAX+1, 0);
        for (int i = 0; i < MAX; i++) s[i+1] = s[i] + a[i];

        for (int i = 0; i < n; i++) {
                cout << s[r[i]+1] - s[l[i]] << endl;
        }
}

Measured memory_bytes: 5612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner sin = new Scanner();
			string s = sin.Next();
			Hoge(s);
			
		}

		public static void Hoge(string s)
		{
			DateTime d = DateTime.Parse(s);
			DateTime h = new DateTime(2019, 4, 30);
			if (d <= h) {
				Console.WriteLine("Heisei");
			} else {
				Console.WriteLine("TBD");
			}
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13660
#include <stdio.h>
#include <stdlib.h>
#define N 100000
#define M -1

typedef struct{
  int p; //parent
  int l; //左の子
  int r; //右兄弟
}NODE;

void GetDepth(NODE *,int,int,int *); //木、子の位置、深さ、深さ(保存用)

int main()
{
  int n,depth[N],i,node,degree,j,child,left,t,num;
  NODE T[N];

  scanf("%d",&n);
  if(n>N) exit(1);
  
  for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = M; //全部-1にすることで後でrootなどの判定ができる

  for(i=0;i<n;i++){
    scanf("%d %d",&node,&degree);
    for(j=0;j<degree;j++){
      scanf(" %d",&child);
      if(j==0) T[node].l = child; //一番左の子を設定
      else T[left].r = child; //左の子の右兄弟に設定
      left = child;
      T[child].p = node; //
    }
  }
  for(i=0;i<n;i++)
    if(T[i].p == M) t=i; //rootを探す

  GetDepth(T,t,0,depth);
      
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,depth[i]);
    if(T[i].p == M) printf("root, ");
    else if(T[i].l == M) printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    child = T[i].l;
    for(j=0;child!=M;j++){ 
      if(j>0) printf(", ");
      printf("%d",child);
      child = T[child].r; //右の兄弟にchildを移動していく→標準表示とループを抜ける判定ができる
    }
    printf("]\n");
  }
  
  return 0;
}

void GetDepth(NODE *T,int t,int num,int *depth)
{
  depth[t] = num; //深さを与える
  if(T[t].r != M) GetDepth(T,T[t].r,num,depth); //右の兄弟がいたら、右の兄弟に同じ深さ
  if(T[t].l != M) GetDepth(T,T[t].l,num+1,depth); //一番左の子に深さ+1
}



Measured memory_bytes: 7944
#include<bits/stdc++.h>
#define rint register int
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for (; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}

namespace {
  const int mo = 998244353;
  inline int add(int x, int y) {
    if((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
  inline int pw(int a, int k, int mo) {
    int ans = 1;
    for(; k; k >>=1, a = mul(a, a))
      if(k & 1) ans = mul(ans, a);
    return ans;
  }
}
const int N = 7e4 + 233;
int fac[N], fac_inv[N];
int n, a, b;
char s[N], t[N];
inline void init(void) {
  fac[0] = 1;
  for (int i = 1; i < N; i ++)
    fac[i] = mul(fac[i - 1], i);
  fac_inv[N - 1] = pw(fac[N - 1], mo - 2, mo);
  for (int i = N - 2; i >= 0; i --)
    fac_inv[i] = mul(fac_inv[i + 1], i + 1);
}

namespace Poly {
  const int G = 3;
  int rev[N], a[N], b[N], ans[N];
  int n, m;
  inline void FFT(int *p, int fff, int n) {
    for (int i = 0; i < n; i ++)
      if (i < rev[i])
        swap(p[i], p[rev[i]]);
    for (int l = 2; l <= n; l <<= 1) {
      int w = pw(G, (mo - 1) / l, mo);
      if (fff == -1) w = pw(w, mo - 2, mo);
      for (int *a = p, m = l >> 1; a != p + n; a += l) {
        for (int k = 0, wn = 1; k < m; k ++, wn = mul(wn, w)) {
          int x = a[k], y = mul(a[k + m], wn);
          a[k] = add(x, y);
          a[k + m] = sub(x, y);
        }
      }
    }
    if (fff == -1) {
      int tmp = pw(n, mo - 2, mo);
      for (int i = 0; i < n; i ++)
        p[i] = mul(p[i], tmp);
    }
  }
  inline void debug(int a[], int n) {
    for (int i = 0; i < n; i ++)
      cout << a[i] << " "; puts("");
  }
  inline void Mul(int a[], int b[], int ans[]) {
    static int ta[N], tb[N];
    for (int i = 0; i < m; i ++)
      ta[i] = a[i], tb[i] = b[i];
    FFT(ta, 1, m); FFT(tb, 1, m);
    for (int i = 0; i < m; i ++) {
      ans[i] = mul(ta[i], tb[i]);
    }
    FFT(ans, -1, m);
    for (int i = n + 1; i < m; i ++)
      ans[i] = 0;
  }
  inline void init(int _n) {
    n = _n;
    a[0] = 1;
    for (int i = 0; i <= n; i ++)
      b[i] = fac_inv[i + 1];
    int L = -1;
    for (m = 1; m <= n + n + 1; m <<= 1) L ++;
    for (int i = 0; i < m; i ++)
      rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << L);
  }
  inline void fastpow(int k) {
    // debug(b, m);
    // debug(a, m);
    for (; k; k >>= 1, Mul(b, b, b))
      if (k & 1) Mul(a, b, a);
  }  
}

inline int doit(void) {
  Poly::init(a);
  Poly::fastpow(b);
  int ans = 0;
  for (int i = 0; i <= a; i ++)
    ans = add(ans, Poly::a[i]);
  ans = mul(ans, mul(fac[a + b], mul(fac[a], fac[b])));
  return ans;
}

main(void) {
  init();
  scanf("%s%s", s + 1, t + 1);
  n = (int) strlen(s + 1);
  for (int i = 1; i <= n; i ++) {
    a += s[i] == '1' && t[i] == '1';
    b += s[i] == '1' && t[i] == '0';
  }
  cout << doit() << "\n";
}


Measured memory_bytes: 1536
#include <stdio.h>

int main()
{
  double a,b=0,c=999;
  for(;~scanf("%lf",&a);)
    {
      if(b<a)b=a;
      if(c>a)c=a;
    }
  //  printf("%f\n%f\n",b,c);
  printf("%lf\n",b-c);
  exit(0);
}

Measured memory_bytes: 648
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    size_t x;
    cin >> x;
    bitset<32> b(x);
    cout << b << endl;
    cout << (~b) << endl;
    cout << (b<<1) << endl;
    cout << (b>>1) << endl;
}



Measured memory_bytes: 3220
L = [int(i) for i in input().split()]
flag=0
for i in range(L[0]+1):
    # print(L[1]-i*2-(L[0]-i)*4)
    if L[1]-i*2-(L[0]-i)*4==0:
        print("Yes")
        flag=1
        break
    # if L[1]<i*2+(L[0]-i)*4:
    #     print("df")
    #     break

if flag==0:
    print("No")

Measured memory_bytes: 9184
s = int(input())
a = s
c = 0
if a == 1 or a == 2:
  ans = 4
else:
  while a != 1:
    if a%2 == 0:
      a = int(a/2)
      c += 1
    else:
      a = int(3*a+1)
      c += 1
  ans = c+2
print(ans)

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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<string> S(H);
    for (int i = 0; i < H; i++)
    {
        cin >> S.at(i);
    }

    int cnt;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (S.at(i).at(j) == '#')
            {
                cout << '#';
            }
            else
            {
                cnt = 0;
                for (int ud = -1; ud <= 1; ud++)
                {
                    for (int lr = -1; lr <= 1; lr++)
                    {
                        if (0 <= i + ud && i + ud < H && 0 <= j + lr && j + lr < W)
                        {
                            if (S.at(i + ud).at(j + lr) == '#')
                            {
                                cnt++;
                            }
                        }
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
long long getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;

// code
// ------------------------------------------------
int main() {

  ll x;
  cin >> x;

  for(ll i = -200; i <= 200; ++i)
  for(ll j = -200; j <= 200; ++j)
  {
    if(x == pow(i,5) - pow(j,5))
    {
      cout << i << " " << j << endl;
      return 0;
    }
  }


  return 0;
}
// funcの実体
// ------------------------------------------------
ll getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
ll CalcSumOfDigit(ll n)
{
  ll s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define REP(i,n)for(int i=0;i<n;i++)
using namespace std;int n,k,a,u,v;vector<int>e[2010];int t(int x,int p,int d,int m){if(d==m)return 1;int s=1;for(int i:e[x])if(i!=p)s+=t(i,x,d+1,m);return s;}int main(){cin>>n>>k;REP(i,n-1)cin>>u>>v,e[u-1].push_back(v-1),e[v-1].push_back(u-1);if(k&1)REP(i,n)for(int j:e[i])a=max(a,t(i,j,0,k/2)+t(j,i,0,k/2));else REP(i,n)a=max(a,t(i,-1,0,k/2));cout<<n-a;}

Measured memory_bytes: 384
#include <stdio.h>
int main() {
    int H, W, i, k;
    while(1) {
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(i = 0; i < H; i++) {
            for(k = i; k < W + i; k++) {
                if(k % 2 == 0) {
                    printf("#");
                } else {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL N;
  cin >> N;
  map<LL, LL> m;
  VEC<LL> A(N);
  REP(i, 0, N) {
    cin >> A[i];
    m[A[i]]++;
  }
  LL U = 0;
  for (auto v : m) {
    U += v.second * (v.second - 1) / 2;
  }
  // DUMP(m,U);
  REP(i, 0, N) {
    LL cnt = m[A[i]];
    LL ans = U - cnt * (cnt - 1) / 2 + (cnt - 1) * (cnt - 2) / 2;
    printf("%lld\n", ans);
  }

  return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>

int main(void) {
	int A[100][100];
	int B[100];
	int m, n, i, j, Product;
	Product=0;
	scanf("%d%d", &n, &m);
	for (i=0; i<n; i++)
	{
		for (j=0; j<m; j++)
		{
			scanf("%d", &A[i][j]);
		}
	}
	for (i=0; i<m; i++)
	{
		scanf("%d", &B[i]);
	}
	for (i=0; i<n; i++)
	{
		for (j=0; j<m; j++)
		{
			Product+=A[i][j]*B[j];
		}
		printf("%d\n", Product);
		Product=0;
	}
	return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1e9+7) {
  int val = (a % mod) + (b % mod);
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

string K;
int D;

int dp[11111][2][111];

signed main() {
  cin >> K >> D;
  int n = K.size();

  dp[0][0][0] = 1;
  for (int digit = 0; digit < n; digit++) {
    for (int smaller : {0, 1}) {
      for (int modD = 0; modD < D; modD++) {
        int lim = (smaller == 1 ? 9 : K[digit] - '0');
        for (int num = 0; num <= lim; num++) {
          Add(dp[digit+1][smaller || num < lim][(modD + num) % D], dp[digit][smaller][modD]);
        }
      }
    }
  }

  int ans = 0;
  for (int smaller : {0, 1}) {
    Add(ans, dp[n][smaller][0]);
  }
  Add(ans, -1LL);

  cout << ans << endl;

  return 0;
}

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

int main() {
    // エラトステネスのふるい
    int MAX = 101010;
    vector<int> is_prime(MAX, 1);
    is_prime[0] = 0, is_prime[1] = 0;
    for (int i = 2; i < MAX; ++i) {
        if (!is_prime[i]) continue;
        for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
    }

    // 2017-like 数かどうか
    vector<int> a(MAX, 0);
    for (int i = 0; i < MAX; ++i) {
        if (i % 2 == 0) continue;
        if (is_prime[i] && is_prime[(i+1)/2]) a[i] = 1;
    }

    // 累積和
    vector<int> s(MAX+1, 0);
    for (int i = 0; i < MAX; ++i) s[i+1] = s[i] + a[i];

    // クエリ処理
    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;

        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 2424
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main(){
  int n,m;
  cin >>n>>m;
  vector<int> lot;
  for(int i=0; i<n; i++) lot.push_back(i+1);
  for(int i=0,a,b,c; i<m; i++){
    scanf("%d,%d",&a,&b);
    c = lot[a-1];
    lot[a-1] = lot[b-1];
    lot[b-1] = c;
  }
  for(int i=0; i<n; i++) cout <<lot[i]<<endl;
  return 0;
}

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

using namespace std;

typedef long long  ll;

void InsertionSort(vector<int> &a, int n, int g, int &cnt)
{
    for (int i = g; i < n; ++i) {
        int v = a[i], j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j -= g;
            ++cnt;
        }
        a[j + g] = v;
    }
}

void ShellSort(vector<int> a, int n)
{
    if (n == 1) {
        cout << "1\n1\n0\n" << a[0] << '\n';
        return ;
    }

    int cnt = 0;
    vector<int> g;

    for (int h = 1; h < n; ) {
        g.emplace_back(h);
        h = 3 * h + 1;
    }

    int m = g.size();

    cout << m << "\n";
    for (int i = m - 1; i >= 0; --i) {
        cout << g[i] << (i == 0 ? '\n' : ' ');
        InsertionSort(a, n, g[i], cnt);
    }
    cout << cnt << "\n";
    for (int i = 0; i < n; ++i)
        cout << a[i] << '\n';
}

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

    int n;

    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    ShellSort(a, n);

    return 0;
}

Measured memory_bytes: 8848
def main():
    S = input()
    T = input()
    d = dict()
    for s, t in zip(S, T):
        if s not in d.keys():
            if t in d.values():
                print('No')
                return
            d[s] = t
        else:
            if d[s] != t:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
 
int main(){
    int n;
    cin>>n;
    int ans = 0;
    rep(i,n){
        int l,r;
        cin>>l>>r;
        ans += r-l+1;
    }
    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 std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    ll ans=0;
    if(n>k){
        ans+=k*x+(n-k)*y;
    }
    else{
        ans+=n*x;
    }
    cout<<ans;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int nxt[300001][27];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string a, b;
	cin>>a>>b;
	int n = a.length();
	int m = b.length();
	a+=a;
	memset(nxt,-1,sizeof(nxt));
	for(int i = 2*n - 1; i >= 0; i--)
	{
		nxt[i][a[i]-'a']=i;
		for(int j = 0; j < 26; j++)
		{
			if(j==a[i]-'a') continue;
			if(i<2*n-1)
			{
				nxt[i][j]=nxt[i+1][j];
			}
		}
	}
	int cnt = 1;
	int cur = 0;
	for(int i = 0; i < m; i++)
	{
		int c = b[i]-'a';
		cur=nxt[cur][c];
		if(cur==-1)
		{
			cout<<-1<<'\n';
			return 0;
		}
		if(cur>=n)
		{
			cur-=n;
			cnt++;
		}
		if(i+1<m)
		{
			cur++;
			if(cur>=n&&i<m-1)
			{
				cur-=n;
				cnt++;
			}
		}
	}
	ll N = a.length()/2;
	cout<<(cnt-1)*1LL*N+cur+1<<'\n';
}


Measured memory_bytes: 32364
#include<iostream>
#include<climits>
using namespace std;
 
int N,K;
int A[100001];
 
int main() {
    cin>>N>>K;
    for(int i=0;i<N;i++) {
        cin>>A[i];
    }
 	cout<<(N-2)/(K-1)+1;
}

Measured memory_bytes: 640
n,k = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
t = (k*(k-1))//2
ans = 0
cnt1,cnt2 = 0,0
for i in range(n):
    for j in range(i,n):
        if A[i]>A[j]:
            cnt1 += 1
cnt1 *= k

for i in range(n):
    for j in range(n):
        if A[i]>A[j]:
            cnt2 += 1

cnt2 *= t
print((cnt1+cnt2)%MOD)


Measured memory_bytes: 3188
import java.util.*;

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		while(in.hasNext()){
			int n = in.nextInt();
			if(n == 0) return;

			boolean f = false;
			int cnt = 0;

			for(int i = 0; i < n; i++){
				int k = in.nextInt();
				if( k > 1) f = true;
				if(k == 0) cnt++;
			}

			if(f) System.out.println(n + 1 - cnt);
			else System.out.println("NA");

		}
	}

	
}

Measured memory_bytes: 153544
List=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K=int(input())
print(List[K-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e3 + 5;
const ll LINF = 1e18 + 5;
int n, m, pre[N];
vector <int> G[N], ans;
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=m; i++)
 	{
 		int u, v;
 		cin >> u >> v;
 		G[u].pb(v);
 	}
 	for(int i=1; i<=n; i++)
 	{
 		memset(pre+1, 0, n*sizeof(int));
 		queue <int> q;
 		for(int v : G[i])
 		{
 			pre[v] = i;
 			q.push(v);
 		}
 		while(sz(q))
 		{
 			int u = q.front(); q.pop();
 			if(u==i)
 			{
 				vector <int> loop;
 				int x = pre[u];
 				while(x!=i)
 				{
 					loop.pb(x);
 					x = pre[x];
 				}
 				loop.pb(x);
 				if(!sz(ans) || sz(loop)<sz(ans)) swap(loop, ans);
 				break;
 			}
 			for(int v : G[u])
 			{
 				if(!pre[v])
 				{
 					pre[v] = u;
 					q.push(v);
 				}
 			}
 		}
 	}
 	if(sz(ans))
 	{
 		cout << sz(ans) << '\n';
 		reverse(all(ans));
 		for(int x : ans) cout << x << '\n';
 	}
 	else cout << -1 << '\n';
	return 0;
}


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


typedef long long i64;
const int inf = (int)1.05e9;

struct UnionFind {

	vector<int> par;

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

	int root(int x)
	{
		if(par[x] == x) {
			return x;
		} else {
			return par[x] = root(par[x]);
		}
	}

	bool same(int a, int b)
	{
		return root(a) == root(b);
	}

	int unite(int a, int b)
	{
		a = root(a);
		b = root(b);

		if(a != b) {
			par[b] = a;
		}

		return a;
	}
};

struct Data {
	int num_edge;
	int prev_ok;
	i64 max_edge;
	i64 sum_vertex;
};

int main()
{
	int n, m;
	vector<int> xs;
	vector<pair<i64, pair<int,int>>> edges;

	scanf("%d%d", &n, &m);
	xs.resize(n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &xs[i]);
	}
	for(int i = 0; i < m; ++i) {
		int a, b;
		i64 y;
		scanf("%d%d%lld", &a, &b, &y);
		edges.push_back({y, {a - 1, b - 1}});
	}

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

	int ans = 0;
	UnionFind uf;

	uf.init(n);

	vector<Data> data(n);

	for(int i = 0; i < n; ++i) {
		data[i].num_edge = 0;
		data[i].max_edge = 0;
		data[i].sum_vertex = xs[i];
		data[i].prev_ok = 0;
	}

	for(auto& e : edges) {

		int x = e.second.first;
		int y = e.second.second;
		i64 w = e.first;

		int a = uf.root(x);
		int b = uf.root(y);

		if(a == b) {

			data[a].num_edge += 1;
			data[a].max_edge = max(data[a].max_edge, w);

		} else {

			int c = uf.unite(a, b);
			a = c;

			data[a].num_edge += data[b].num_edge + 1;
			data[a].max_edge = max(max(data[a].max_edge, data[b].max_edge), w);
			data[a].sum_vertex += data[b].sum_vertex;
			data[a].prev_ok += data[b].prev_ok;

		}

		if(data[a].max_edge <= data[a].sum_vertex) {
			ans = ans - data[a].prev_ok + data[a].num_edge;
			data[a].prev_ok = data[a].num_edge;
		}
	}

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

	return 0;
}

/* waffle */


Measured memory_bytes: 4976
# 町a,b(a < b)の距離をあらかじめdictionaryで保存しておく
# そのうえで、全探索可能

import sys
readline = sys.stdin.readline

N = int(readline())
town = [None] * N
for i in range(N):
  town[i] = tuple(map(int,readline().split()))

from collections import defaultdict
dist = defaultdict(float)

for i in range(N - 1):
  for j in range(i + 1, N):
    ix,iy = town[i]
    jx,jy = town[j]
    dist[(i,j)] = ((ix - jx) ** 2 + (iy - jy) ** 2) ** 0.5
    
# 距離を求めたので、あとは全パターン検索
ans = 0
import itertools
for perm in itertools.permutations(range(N)):
  d = 0
  for i in range(1, len(perm)):
    a,b = perm[i - 1],perm[i]
    if a > b:
      a,b = b,a
    d += dist[(a, b)]
  ans += d
  
pat = 1
for i in range(2, N + 1):
  pat *= i
print(ans / pat)

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  ll X,K,D;
  cin>>X>>K>>D;
  X = abs(X);
  ll cnt = X/D;
  if(cnt > K){
    cout << X - K*D << endl;
    return 0;
  }
  ll amari1 = X-cnt*D, amari2 = abs(X-(cnt+1)*D);
  if((K - cnt)%2 == 0){
    cout << amari1 << endl;
  }else{
    cout << amari2 << endl;
  }
  return 0;
}



Measured memory_bytes: 3628
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;

int main(void)
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> p[3];
    ll ans = 0;
    // p[0] R p[1] G p[2] B
    REP(i, s.length())
    {
        if (s[i] == 'R')
        {
            p[0].push_back(i);
            //s[i] = '0';
        }
        else if (s[i] == 'G')
        {
            p[1].push_back(i);
            //s[i] = '1';
        }
        else
        {
            p[2].push_back(i);
            //s[i] = '2';
        }
    }
    REP(i, 3)
    sort(p[i].begin(), p[i].end());

    REP(i, s.length())
    {
        rep(j, i + 1, s.length())
        {
            if (s[i] == s[j])
                continue;
            // i -> j -> k
            // iとjの文字をもとにkとして満たす個数をカウントする
            // j-i != k -jのみのぞく
            char tmp;
            int num = 0;
            if ((s[i] == 'R' and s[j] == 'G') or (s[j] == 'R' and s[i] == 'G'))
            {
                tmp = 'B';
                num = 2;
            }
            else if ((s[i] == 'R' and s[j] == 'B') or (s[j] == 'R' and s[i] == 'B'))
            {
                tmp = 'G';
                num = 1;
            }
            else
            {
                tmp = 'R';
            }

            /*
            rep(k, j + 1, s.length())
            {
                if (s[k] == tmp)
                {
                    if (k != 2 * j - i)
                    {
                        ans++;
                    }
                }
            }
            */
            vector<int>::iterator r = lower_bound(p[num].begin(), p[num].end(), j + 1);
            // 1 2 3 4 5 6
            // int idx = distance(p[num].begin(), r);
            int kosuu = p[num].end() - r;

            int rem = j + (j - i);
            if (binary_search(p[num].begin(), p[num].end(), rem))
                kosuu--;
            ans += kosuu;
            //cout << i << " " << j << " " << kosuu << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
n, d = map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

ans = 0
for i in range(n):
    di = (int(x[i])**2 + int(y[i])**2)**(0.5)
    if di <= d:
        ans += 1
        
print(ans)

Measured memory_bytes: 116736
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    vector<int> a(n+1),b(n);
    int i;
    for(i=0; i<n+1; i++) {
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%d", &b[i]);
    }
    ll cnt=0;
    for(i=0; i<n; i++) {
        int tmp=MIN(a[i],b[i]);
        cnt+=tmp;
        a[i]-=tmp;
        b[i]-=tmp;

        tmp=MIN(b[i],a[i+1]);
        cnt+=tmp;
        a[i+1]-=tmp;
        b[i]-=tmp;        
    }
    printf("%lld\n", cnt);

    return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              long long int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x){return (n-1)/x+(n>0);}

ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll pow1(ll n,ll m ,ll mod=MOD );
ll pow2(ll n,ll k);

ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}

bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
ll const N=(ll)1e6+11;

void solve(){
        ll i,j,k,l,n,m,x,y,z,r;
        
        string s;
        cin>>s;
        n=s.sz;
        for(i=0;i<n;i++){
                if(s[i]=='?'){
                        s[i]='D';
                }
        }
        cout<<s<<endl;
        
                
        
}
int main(){
        FS;
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}


ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}

ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string c;
	cin >> c;
	if (c[0] == 'a' || c[0] == 'i' || c[0] == 'u' || c[0] == 'e' || c[0] == 'o')
		cout << "vowel" << "\n";
	else
		cout << "consonant" << "\n";
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
// template<typename T>
// ostream& operator<<(ostream& os, const vector<T>& v){
//   const char* dlm = "";
//   for(const auto& x:v) os << exchange(dlm, "\n") << x;
//   return os;
// }
auto bracket_matcher(const string& str){
  vector<int32_t> que;
  vector<tuple<int32_t,int32_t>> ret;
  for(int32_t i=0; i<str.size(); ++i){
    if(str[i]=='\\'){
      que.push_back(i);
    } else if(str[i]=='/'){
      if(!que.empty()){
        int32_t x=que.back(); que.pop_back();
        int32_t tmp_area=0;
        while(!ret.empty() && get<0>(ret.back())>x){
          tmp_area+=get<1>(ret.back()); ret.pop_back();
        }
        ret.emplace_back(x,tmp_area+i-x);
      }
    }
  }
  return ret;
}
int32_t main(){
  string str; cin>>str;
  auto ret=bracket_matcher(str);
  cout<<accumulate(begin(ret),end(ret),0,[](const auto& x,const auto& y){return x+get<1>(y);})<<endl<<ret.size();
  for(const auto& x:ret) cout<<' '<<get<1>(x);
  cout<<endl;
}


Measured memory_bytes: 3296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Stack;

public class Main {
	
    public static void main(String[] args) throws IOException {
    	Scanner s = new Scanner(System.in);
    	String str = s.next();
    	System.out.println(str.substring(0, 3));
    }
}


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

int main(){
int a,b;
cin>>a>>b;
if (b>=a)
{
    /* code */
    cout<<a<<endl;
}

else
{
    cout<<a-1<<endl;
}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int k = b-a;
  if(k%2==0){
    cout<<"Alice"<<endl;
  }else{
    cout<<"Borys"<<endl;
  }
  return 0;
}

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

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

		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();

		int[] p=new int[N];

		for(int i=0;i<N;i++) p[i]=sc.nextInt();

		sc.close();

		int cnt=0;

		for(int i=0;i<N-2;i++){

			int second=min_2(p[i],p[i+1],p[i+2]);

			if(p[i+1]==second) cnt++;
		}

		System.out.println(cnt);

	}

	public static int min_2(int a,int b,int c){

		int[] box=new int[3];

		box[0]=a;
		box[1]=b;
		box[2]=c;

		Arrays.sort(box);

		return box[1];
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
#define sz(x) (ll)x.size()
using namespace std;
 
 
const ll MOD = 998244353;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
 


const ll N =(5e5+5);

ll fact[N];

long long binpow(long long a, long long b) {
     a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
     res%=MOD;
    return res;
}
void ini(){
    fact[0] = 1;
    for(int i = 1;i < N;i++){
        fact[i] = (fact[i-1] * i)%MOD;
    }
}
ll ncr(ll n,ll r){
    ll ret = fact[n];
    ret = (ret * binpow(fact[r],MOD-2))%MOD;
    ret = (ret * binpow(fact[n-r],MOD-2))%MOD;
    return ret;
}
ll a[N];
ll pre[N];
ll suf[N];
void solve(){
    ll n;
    cin >> n;


    for(int i =1;i<=n;i++){
        cin >> a[i];
        pre[i] = pre[i-1] + a[i];
    }
    for(int i = n;i>=1;i--){
        suf[i] = suf[i+1] + a[i];
    }
    ll ans = INF;
    for(int i = 1;i < n;i++){
        ans = min(ans,abs(pre[i]-suf[i+1]));
    }
    cout << ans << endl;




}   
/*
5
abcab
aabab

aabbc
aaabb

*/

 
   
 
 
 /*
 2 3 4 5 6 1
 3 6 10 15 21 
 4 10 20 35 56 
 5 15 35 70 126 
 6 21 56 126 252 
*/
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
       
 
     ll tt=1;
    while(tt--){
        solve();
    }    
}

Measured memory_bytes: 9984
/*
AizuOnline A1141
Dirichlet's Theorem on Arithmetic Progressions
*/
#include <stdio.h>
#include <math.h>

#define ALIMIT 9307
#define DLIMIT 346
#define NLIMIT 210

int primes[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,
	      101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,
	      211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,
	      307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,
	      401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,
	      503,509,521,523,541,547,557,563,569,571,577,587,593,599,
	      601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,
	      701,709,719,727,733,739,743,751,757,761,769,773,787,797,
	      809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,
	      907,911,919,929,937,941,947,953,967,971,977,983,991,997};

long int a,d,n;
int not_prime[NLIMIT+1];
void set_not_prime(int y,int p)
{
  int i;

  for(i=0;y+i*p<NLIMIT;i++)
    not_prime[y+i*p]=1;
}
isprime(int x)
{
  int i;
  long int num;
  int flag;

  flag=1;
  num=a+d*x;
  //printf("%ld:",num);
  // if(not_prime[x]==1)
  //  return(0);
  if(num==1)return(0);
  for(i=0;primes[i]<=(int)(sqrt((float)num));i++)
    {
      //printf(";%ld %d %ld;\n",num,primes[i],(num % primes[i]));

	if(num % primes[i] == 0)
	  { // set_not_prime(x,primes[i]);
	    flag = 0;
	  }
    }
  return(flag);
}
main()
{
  int i,cnt,num;

  while(EOF != scanf("%ld %ld %ld",&a,&d,&n) && (a || d || n))
    {
      cnt = 0;i = 0;
      while(1)
	{
	  //printf(">%d::",a+i*d);
	  if(isprime(i))
	    {
	      cnt++;
	      if(cnt == n)
		{
		  printf("%ld\n",((long)a+i*d));
		  goto NEXT;
		}
	    }
	  i++;
	}
    NEXT:
      ;
    }
return(0);
}

Measured memory_bytes: 600
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 10;

struct poke {
	char ch;
	int num;
}A[100010],B[100010], L[50005], R[50005];
int partition(poke A[], int p, int r) {
	poke x = A[r];
	int i = p - 1;
	for (int j = p; j < r; j++) {
		if (A[j].num <= x.num) swap(A[++i], A[j]);
	}
	swap(A[++i], A[r]);
	return i;
}
void quicksort(poke A[], int p, int r) {
	int pos;
	if (p < r) {
		pos = partition(A, p, r);
		quicksort(A, p, pos-1);
		quicksort(A, pos + 1, r);
	}
}

void merge(poke A[], int le, int mid,int r) {
	int n1 = mid - le, n2 = r - mid;
	L[n1].num = R[n2].num = 2*1e9;
	for (int i = 0; i < n1; i++) L[i] = A[le+i];
	for (int i = 0; i < n2; i++) R[i] = A[mid+i];
	int i = 0, j = 0;
	for (int k = le; k < r; k++) {
		if (L[i].num <= R[j].num) A[k] = L[i++];
		else A[k] = R[j++];
	}
}
void mergesort(poke A[], int le, int r) {
	if (le+1 < r) {
		int mid = (r + le) / 2;
		mergesort(A, le, mid);
		mergesort(A, mid, r);
		merge(A, le, mid, r);
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		cin >> A[i].ch >> A[i].num;
		B[i] = A[i];
	}
	int flag = 0;
	quicksort(A, 0, n - 1);
	mergesort(B, 0, n);
	for (int i = 0; i < n; i++) {
		if (A[i].ch != B[i].ch) {
			flag = 1;
			break;
		}
	}
	if (flag) cout << "Not stable" << endl;
	else cout << "Stable" << endl;
	for (int i = 0; i < n; i++) {
		printf("%c %d\n", A[i].ch, A[i].num);
	}


	return 0;
}


Measured memory_bytes: 5536