akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAX = 300100;


int main() {
    long long N, x; cin >> N;
    long long sum[MAX], c[MAX];
    for (int i = 0; i < MAX; i++) {
        sum[i] = 0;
        c[i] = 0;
    }
    for(long long i = 1; i <= N; i++) {
        cin >> x;
        c[x]++;
        sum[c[x]]++;
    }
    for (long long i = 1; i <= N; i++) sum[i] += sum[i - 1];
    for (long long i = 1; i <= N; i++) {
        long long l = 1, r = N, ans = 0, mid;
        while (l <= r) {
            mid = (r - l) / 2 + l;
            if (mid * i <= sum[mid]) {
                ans = mid;
                l = mid+1;
            }
            else
                r = mid-1;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    char c;
    cin >> c;
    char ret = 'a';
    switch (c) {
        case 'A':
            ret = 'T';
            break;
        case 'G':
            ret = 'C';
            break;
        case 'C':
            ret = 'G';
            break;
        case 'T':
            ret = 'A';
            break;
    }

    cout << ret << endl;
    return 0;
};


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

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    ll a, b;
    cin >> a >> b;

    if (a * b <= 0)
        cout << "Zero" << endl;
    else if (b < 0 && (b - a + 1) % 2)
        cout << "Negative" << endl;
    else
        cout << "Positive" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,b;
	cin>>n>>b;
	char a[51];
	for(int i=1;i<=n;i++)
		{
		cin>>a[i];
		if(i==b)
			a[i]+=32;
		}
	for(int i=1;i<=n;i++)
		cout<<a[i];
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include<stack>
using namespace std;
#define PI 3.14159265358979
typedef  long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#include<set>
int main(void)
{
    ll n;
    cin>>n;

    vector<ll> a(n+3);
    rep(i,n)
    {
        cin>>a[i];
    }

    ll hsum = 0;


    for(int i = 1;i<n;i++)
    {
        if(a[i]<a[i-1])
        {
            hsum += (a[i-1]-a[i]);

            a[i] = a[i-1];
        }

    }

    cout<<hsum<<endl;
}

Measured memory_bytes: 4404
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

long long inputValueLongLong(){
    long long a;
    cin >> a;
    return a;
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const long long MOD = 10*10*10*10*10*10*10*10*10+7;

int main(int argc, const char * argv[]) {
    const double PI=3.14159265358979323846;
    // source code
    long long S = inputValueLongLong();
    long long W = inputValueLongLong();

    if(W>=S){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
N,M = map(int, input().split())
ng = set()
for i in range(M):
  ng.add(int(input()))
  
dp = [0] * (N + 5)
dp[0] = 1

for i in range(N):
  for j in range(1, 3):
    if (i + j) not in ng:
      dp[i + j] += dp[i]
      dp[i + j] %= 1000000007

print(dp[N])

Measured memory_bytes: 17432
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        if ((a+b)==c || (a+c)==b || (b+c)==a)
            System.out.println("Yes");
        else
            System.out.println("No");

    }
}

Measured memory_bytes: 21716
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var k = long.Parse(spl[1]);

        var aa = ToIntArray(input.ReadLine(), n);

        var hash = new HashSet<int>();
        var list = new List<int>();

        int i = 0;

        while (true) {
            if (k == 0) {
                return i+1;
            }
            if (hash.Contains(i)) {
                var ll = new List<int>();
                bool sw = false;
                for(int z =0; z<list.Count; z++) {
                    var v = list[z];
                    if (v == i) {
                        sw = true;
                    }
                    if(sw) ll.Add(v);
                }

                return ll[(int)(k % (long)ll.Count)]+1;
            }

            list.Add(i);
            hash.Add(i);
            k--;
            i = aa[i] - 1;
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 50844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

    ll sum[n + 1];
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
        sum[i] = sum[i - 1] + a[i - 1];
    }

    sort(sum, sum + n + 1);

    ll ans = 0;
    int cnt = 1;
    for (int i = 0; i < n; i++) {
        if (sum[i] == sum[i + 1]) cnt++;
        else {
            ans += (ll)cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }
    ans += (ll)cnt * (cnt - 1) / 2;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    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 * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
const int maxn = 1e5 + 5;
ll n, k, f[maxn];

int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    sf(n, k);
    ll ans = 0;
    for (int i = k; i >= 1; --i) {
        f[i] = power(k / i, n);
        for (int j = 2 * i; j <= k; j += i) f[i] -= f[j];
        ans = (ans + i * f[i] % mod) % mod;
    }
    cout << (ans + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int pa[N];
int a[N];
int n,m;
int main (){
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
	cout<<"hon"<<endl;
	else if(n%10==0||n%10==1||n%10==6||n%10==8)
	cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
	return 0;
} 

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
using namespace std;

#define rep(i,n) for(ll i = 0;i < n; i++)

typedef long long ll;

int main(){
    ll N,ans = 0;
    cin >> N;
    ll A[100010];
    ll B[100010];
    rep(i,N) cin >> A[i] >> B[i];
    for(ll i = N-1;i >= 0;i--){
        ans += (B[i] - (A[i] + ans) % B[i]) % B[i];
        }
    cout << ans << endl;
}


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

int main() {
  string s; cin >> s;
  
  int i_a;
  int i_z;
  
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      i_a = i;
      break;
    }
  }
  
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == 'Z') {
      i_z = i;
      break;
    }
  }
  
  int ans = i_z - i_a + 1;
  cout << ans << endl;
}

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

struct UnionFind{
    vector<int> parent;
    UnionFind(int n){
        parent.resize(n);
        for(int i = 0;i < n;i++){
            parent[i] = i;
        }
    }

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        parent[x] = y;
    }
};

int main(){
    int n, q, com, x, y;
    cin >> n >> q;
    auto uf = UnionFind(n);
    for(int i = 0;i < q;i++){
        cin >> com >> x >> y;
        if(com == 0){
            uf.unite(x, y);
        }
        if(com == 1){
            if(uf.root(x) == uf.root(y))
                cout << 1 << endl;
            else 
                cout << 0 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3176
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

vector<int> f(const vector<int>& v) {
    const int n = v.size();
    vector<int> s(n);

    rep(i, n) {
        int l = max(i - v[i], 0);
        ++s[l];

        int r = i + v[i];
        if (r + 1 < n) --s[r + 1];
    }

    rep(i, n - 1) s[i + 1] += s[i];
    return s;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    auto check = [&]() {
        rep(i, n) if (a[i] != n) return false;
        return true;
    };

    rep(i, k) {
        if (check()) break;
        a = f(a);
    }

    rep(i, n) cout << a[i] << " \n"[i == n - 1];
    return 0;
}


Measured memory_bytes: 5096
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
	string s, t;
	cin >> s >> t;
	int d[s.length()][t.length()];

	for (int i = 0; i < s.length(); i++) {
		for (int j = 0; j < t.length(); j++) {
			int a = (i >= 1) ? d[i-1][j] : 0;
			int b = (j >= 1) ? d[i][j-1] : 0;
			int c = (i >= 1 && j >= 1) ? d[i-1][j-1] : 0;
			if (s[i] == t[j]) {
				c++;
			}
			d[i][j] = max({a, b, c});
		}
	}


	int i = s.length()-1;
	int j = t.length()-1;
	string ans = "";
	while ((i >= 0 && j >= 0) && d[i][j] != 0) {
		int a = (i >= 1) ? d[i-1][j] : -5;
		int b = (j >= 1) ? d[i][j-1] : -5;
		int c = (i >= 1 && j >= 1) ? d[i-1][j-1] : -5;
		if (s[i] == t[j]) {
			ans += s[i];
			i--;
			j--;
		} else if (a >= 0 && d[i][j] == a)
			i--;
		else if (b >= 0 && d[i][j] == b)
			j--;
	}

	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>

int main(){
	long long int input, total = 0;
	
	scanf ("%lld", &input);
	
	for (int i = 1; i <= input; i++){
		if(i % 3 != 0 && i % 5 != 0){
        total += i;
    	}
	}
	
	printf ("%lld", total);
	return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define rep(i ,a, n) for (long long int i=a;i<=n;i++)
#define pb  push_back
#define mp make_pair
#define fp first
#define sp second
#define be(v) v.begin(),v.end()
typedef long long ll;
typedef vector<ll> vi ;
typedef vector<pair<ll , ll > >  vpi ;
const int ma1=1e5+5;
string no="NO",yes="YES";
#define MOD 1000000007
int max_char=26;


int main()
{
      ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    while(t--)
    {
         string s;
            cin>>s;
            int sum=0,max1=0;
          for(int i=0;i<3;i++)
            if(s[i]=='S')
            sum++;
          if(sum==3)
            cout<<0;
          else if(sum==0)
            cout<<3;
          else if(sum==2)
            cout<<1;
          else if(sum==1 && s[1]=='S')
            cout<<1;
          else if(sum==1 && s[1]!='S')
            cout<<2;
    }
    return 0;
}
















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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int N = input(), M = input();
  vector< int > A(10, inf), t({inf, 2, 5, 5, 4, 5, 6, 3, 7, 6});

  range(i, 0, M) {
    int s = input();
    A[s] = t[s];
  }

  vector< int > dp(N + 1, -inf);
  dp[0] = 0;
  range(i, 1, 10) {
    range(j, 0, N + 1 - A[i]) {
      chmax(dp[j + A[i]], dp[j] + 1);
    }
  }

  string ans;
  int idx = N;
  rrange(i, 1, 10) {
    while ((idx >= A[i]) && (dp[idx] == dp[idx - A[i]] + 1)) {
      ans += to_string(i);
      idx -= A[i];
    }
 }
      
  cout << ans << endl;
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int start = 10000000;
  int end = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A')
      start = min(i, start);
    else if (s[i] == 'Z')
      end = i;
  }

  cout << end - start + 1 << endl;

  return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> cnt(n, 0);
    cnt[0] = 0;
    rep(i, 0, n - 1)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            cnt[i + 1] = cnt[i] + 1;
        }
        else
        {
            cnt[i + 1] = cnt[i];
        }
    }

    rep(i, 0, q)
    {
        int l, r;
        cin >> l >> r;
        cout << cnt[r - 1] - cnt[l - 1] << '\n';
    }

    return 0;
}

Measured memory_bytes: 1872
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
#define repi(i, n, iv) for (int i = iv; i < n; i++)
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    int N;
    cin >> N;
    cout << (N + N * N + N * N * N) << endl;
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int32_t main(){
   fast;
   int a,b,n;
   cin >> a >> b >> n;
   int m = min(b-1 , n);
   cout << ((m*a)/b);
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
const int mod = 1000000007;
const int modx = 998244353;
#define ll long long
#define readi(x) scanf("%d", &x)
#define reads(x) scanf("%s", x)
#define readl(x) scanf("%I64d", &x)
#define rep(i, n) for (i = 0; i < n; i++)
#define rep1(i, a, b) for (i = a; i < b; i++)
#define rep2(i, a, b) for (i = b; i >= a; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bpc(x) __builtin_popcount(x)
#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<double, double>
#define pic pair<int, char>
#define ddouble long double
#define PI 3.1415926535
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define prod(x, y) ((x % mod) * (y % mod)) % mod
#define add(x, y) ((x % mod) + (y % mod)) % mod
#define ub(a, b) upper_bound(all(a), b)
#define lb(a, b) lower_bound(all(a), b)
#define pqs priority_queue<int, vector<int>, greater<int>>
#define pqb priority_queue<int>
#define mii map<int, int>
#define mll map<ll, ll>
using namespace std;
//using namespace __gnu_pbds;
/*ll power(ll x, ll y)
{
    ll r = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            r = (r*x) % mod;

        y = y>>1;
        x = (x*x) % mod;
    }
    return r;
}*/

void thunder()
{
    int n;
    cin >> n;
    vi h(n), dp(n, INT_MAX);
    dp[0] = 0;
    for (auto &it : h)
        cin >> it;
    int i;
    rep(i, n)
    {
        if (i < n - 1)
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
        if (i < n - 2)
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif*/
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while (t--)
        thunder();
}


Measured memory_bytes: 3896
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using ll = long long;

template <typename T>
T min(T a, T b){
  return (a < b) ? a : b;
}

template <typename T>
class SegTree{
  static const int MAXN = 1000010;
  T INF;
  int n;
  // T A[MAXN*4];
  T* A;
  public:
  SegTree(int size, T INF): INF(INF){
    n = 1;
    while(n < size){
      n *= 2;
    }
    A = new T[MAXN*4];
    for(int i = 0; i < MAXN*4; i++) A[i] = INF;
  }

  T query(int a, int b){
    return _query(a, b, 0, 0, n);
  }

  T _query(int a, int b, int k, int l, int r){
    if(a >= r || b <= l){
      return INF;
    }
    if(l >= a && r <= b){
      return A[k];
    }
    T v1 = _query(a, b, 2*k + 1, l, (l+r)/2);
    T v2 = _query(a, b, 2*k + 2, (l+r)/2, r);
    return min(v1, v2);
  }

  void update(int _idx, int value){
    int offset = n - 1;
    int idx = _idx + offset;
    A[idx] = value;
    while(idx > 0){
      idx = (idx-1)/2;
      A[idx] = min(A[idx*2+1], A[idx*2+2]);
    }
  }
};

int main(void){
  const int INF=1000000010;
  int N, L; cin >> N >> L;
  SegTree<int> rmq(N, INF);
  for(int i = 0; i < N; i++) {
    int a; cin >> a;
    rmq.update(i, a);
  }

  for(int i = 0; i <= N - L; i++){
    if(i == 0){
      cout << rmq.query(i, i+L);
    }else{
      cout << " " << rmq.query(i, i+L);
    }
  }
  cout << '\n';
}



Measured memory_bytes: 18744
R,C,K = map(int,input().split())
J=[0] * K
for i in range(K):
  J[i] = list(map(int,input().split()))

#DP0 = [[0]*(C+2) for i in range(R+2)]
DP1 = [[0]*(C+2) for i in range(R+2)]
DP2 = [[0]*(C+2) for i in range(R+2)]
DP3 = [[0]*(C+2) for i in range(R+2)]

MAP = [[0]*C for i in range(R)]

for x,y,v in J:
    MAP[x-1][y-1] = v
#print(MAP)
for i in range(R):
    for j in range(C):
        DP1[i][j] = max(DP1[i][j-1],DP1[i-1][j]+MAP[i][j],DP2[i-1][j]+MAP[i][j],DP3[i-1][j]+MAP[i][j])
        DP2[i][j] = max(DP2[i][j-1],DP1[i][j-1]+MAP[i][j])
        DP3[i][j] = max(DP3[i][j-1],DP2[i][j-1]+MAP[i][j])

#print(DP1)
#print(DP2)
#print(DP3)
ANS=0
for i in range(R):
    for j in range(C):
        ANS=max(ANS,DP1[i][j],DP2[i][j],DP3[i][j])
print(ANS)



Measured memory_bytes: 375664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
using namespace std;

typedef long long ll;
const int maxn=1e2+10;
int n,dep[maxn],f[maxn],len;
vector<int> g[maxn];

void dfs(int pos,int fa,int forbit){
	dep[pos]=dep[fa]+1;
	f[pos]=fa;
	for(int i=0;i<g[pos].size();++i)
		if(g[pos][i]!=fa&&g[pos][i]!=forbit)
			dfs(g[pos][i],pos,forbit);
}
inline void init(){
	dfs(1,0,0);
	dfs(max_element(dep+1,dep+n+1)-dep,0,0);
	len=*max_element(dep+1,dep+n+1);
	cout<<(len+1)/2<<' ';
}
inline ll calc(ll base,ll maxdep){
	for(int i=1;i<maxdep;++i){
		int res=0;
		for(int j=1;j<=n;++j)
			if(dep[j]==i)
				if(g[j].size()>res)
					res=g[j].size();
		if(i==1&&base==1)
			base*=res;
		else
			base*=res-1;
	}
	return base;
}
inline void work_even(){
	int pos=max_element(dep+1,dep+n+1)-dep;
	while(dep[pos]!=len/2+1)
		pos=f[pos];
	dfs(f[pos],0,pos);
	dfs(pos,0,f[pos]);
	cout<<calc(2,len/2)<<endl;
}
inline void work_odd(){
	int pos=max_element(dep+1,dep+n+1)-dep;
	while(dep[pos]!=len/2+1)
		pos=f[pos];
	ll ans=~(1ll<<63);
	dfs(pos,0,0);
	ans=min(ans,calc(1,len/2+1));
	for(int i=0;i<g[pos].size();++i){
		dfs(pos,0,g[pos][i]);
		dfs(g[pos][i],0,pos);
		ans=min(ans,calc(2,len/2+1));
	}
	cout<<ans<<endl;
}

int main(){
	cin>>n;
	for(int i=1,u,v;i<n;++i){
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	init();
	if(len&1)
		work_odd();
	else
		work_even();
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	deque<char> d;
	for (int i = 0; i < (int)s.length(); i++)
		d.push_back(s[i]);
	for (int i = 0; i <= (int)s.length(); i++)
	{
		bool equal = true;
		for (int j = 0; equal && j < (int)s.length(); j++)
			equal &= d[j] == t[j];
		if (equal)
		{
			cout << "Yes" << endl;
			return 0;
		}
		char c = d.back();
		d.pop_back();
		d.push_front(c);
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
 
using namespace std;
using ll = long long;
using ld = long double;

namespace NyaGadget
{	// MOD ライブラリ
	template<ll mod> struct ModLL
	{
		ll x;

		// コンストラクタ
		ModLL() { x = 0; }
		ModLL(ll x_)
		{
			x = x_ % mod + mod;
			if (x >= mod)
				x -= mod;
		}

		// 符号
		ModLL operator + () const { return x; }
		ModLL operator - () const { return (-x < 0) ? mod - x : -x; }

		// 加減乗除演算子
		ModLL& operator += (ModLL r)
		{
			if ((x += r.x) >= mod)
				x -= mod;
			return *this;
		}
		ModLL& operator -= (ModLL r)
		{
			if ((x -= r.x) < 0)
				x += mod;
			return *this;
		}
		ModLL& operator *= (ModLL r)
		{
			x = (unsigned long long) x * r.x % mod;
			return *this;
		}
		ModLL& operator /= (ModLL r)
		{
			x = x * Inv(r.x, mod) % mod;
			return *this;
		}

		ModLL operator + (ModLL r) const { return ModLL(*this) += r; }
		ModLL operator - (ModLL r) const { return ModLL(*this) -= r; }
		ModLL operator * (ModLL r) const { return ModLL(*this) *= r; }
		ModLL operator / (ModLL r) const { return ModLL(*this) /= r; }

		// 逆元 x^{-1} (主に除算演算子で使用)
		ll Inv(ll a, ll m)
		{
			ll b = m, u = 1, v = 0;

			while (b)
			{
				ll t = a / b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}

			u %= m;

			return (u < 0) ? u + m : u;
		}

		// 比較演算子
		bool operator == (ModLL& r) const { return x == r.x; }
		bool operator != (ModLL& r) const { return x != r.x; }
		bool operator <  (ModLL& r) const { return x < r.x; }
		bool operator <= (ModLL& r) const { return x <= r.x; }
		bool operator >  (ModLL& r) const { return x > r.x; }
		bool operator >= (ModLL& r) const { return x >= r.x; }

		// 入出力演算子
		friend ostream& operator << (ostream& s, ModLL<mod> a)
		{
			s << a.x;
			return s;
		}
		friend istream& operator >> (istream& s, ModLL<mod>& a)
		{
			s >> a.x;
			return s;
		}
	};
}
 
#define all(collection) (collection).begin(), (collection).end()              // begin to end
#define divc(a, b) ceil((ld) a / (ld) b);		                              // div ceiling
#define rep(i, begin, end) for (ll i = begin; i < end; i++)                   // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)                  // repeat reverse
#define size(collection) ((ll) (collection).size())                           // collection size
// 黒魔術マクロ https://stackoverflow.com/a/54156664
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, v) fori(i, auto& e: v)
#define forir(i, ...) if(ll i = size(v)) for(__VA_ARGS__) if(i--, true)
#define eachr(i, e, v) forir(i, auto& e: boost::adaptors::reverse(v))

using namespace NyaGadget;
using mll = ModLL<1000000007>;

int main(void)
{
	string s; cin >> s;
	s.insert(0, " ");
	vector<vector<mll>> dp;
	dp.resize(size(s));
	each(i, e, dp)
		e.resize(13);

	dp[0][0] = 1;
	each(i, e, s)
	{
		if (i == 0) continue;
		if (e != '?')
		{
			rep(j, 0, 13)
				dp[i][(j * 10 + ((ll)e - (ll)'0')) % 13] += dp[i - 1][j];
		}
		else
		{
			rep(q, 0, 10)
			{
				rep(j, 0, 13)
					dp[i][(j * 10 + (q)) % 13] += dp[i - 1][j];
			}
		}
	}

	cout << dp.back()[5];
	return 0;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  map<ll, ll> mp;
  rep(i,3){
    int n; cin >> n;
    mp[n]++;
  }
  if(mp[5] == 2 && mp[7] == 1){
    cout << "YES";
  }
  else{
    cout << "NO";
  }
}

Measured memory_bytes: 3604
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











 
int main(){
    string s;
    ll k;
    cin >> s >> k;
    bool f = true;
    REP(i, s.size() - 1){
        if(s[i] != s[i + 1]){
            f = false;
            break;
        }
    }
    if(f){
        cout << s.size() * k / 2 << endl;
        return 0;
    }
    if(s[0] == s[s.size() - 1]){
        ll c1 = 0, c2 = 0;
        REP(i, s.size()){
            if(s[0] != s[i]){
                break;
            }
            c1++;
        }
        REP(i, s.size()){
            if(s[s.size() - 1] != s[s.size() - 1 - i]){
                break;
            }
            c2++;
        }
        ll cnt = 0;
        REP(i, s.size() - 1){
            if(s[i] == s[i + 1]){
                s[i + 1] = '_';
                cnt++;
            }
        }
        cout << cnt * k - (c1 / 2 + c2 / 2 - (c1 + c2) / 2) * (k - 1) << endl;
    }
    else{
        ll cnt = 0;
        REP(i, s.size() - 1){
            if(s[i] == s[i + 1]){
                s[i + 1] = '_';
                cnt++;
            }
        }
        cout << cnt * k << endl;
    }
}

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

int main()
{
    int n, h, w;
    cin >> n;
    cin >> h;
    cin >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    return 0;
}

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

using namespace std;

int main () {
  int n;
  cin>>n;
  vector<pair<int, int>> v;
  for(int i=0; i<n; i++)
  {
    int x, y;
    cin>>x>>y;
    v.push_back({x, y});
  }
  bool flag=false;
  for(int i=0; i<n-2; i++)
  {
    if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
    {
      flag=true;
    }
  }
  if(flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}

Measured memory_bytes: 3628
import itertools

h, w, k = map(int, input().split())

d = []
for i in range(h):
	d.append(input())

ph = list(itertools.product([0,1], repeat=h))
pw = list(itertools.product([0,1], repeat=w))

c = 0
ans = 0
for i in ph:
	for j in pw:
		for m in range(h):
			for n in range(w):
				if d[m][n]=='#' and i[m]==0 and j[n]==0:
					c += 1
		if c == k:
			ans += 1
		c = 0

print(ans)

Measured memory_bytes: 9220
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 0;
    if(n % 2 == 0){
      ans = n / 2;
    }else{
      ans = n / 2;
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>

using namespace std;

void sort_and_print(vector<int>& a) {
	int val,ind;
	int size = a.size();
	for (int j = 0; j < size; ++j) {
		cout << a[j];
		if (j < size-1) {
			cout << " ";
		}
	}
	cout << endl;
	for (int i = 1; i < size; ++i) {
		val = a[i];
		ind = i-1;
		while (ind >= 0 && a[ind] > val) {
			a[ind+1] = a[ind];
			--ind;
		}
		a[ind+1] = val;	
		for (int j = 0; j < size; ++j) {
			cout << a[j];
			if (j < size-1) {
				cout << " ";
			}
		}
		cout << endl;
	}
}

int main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort_and_print(a);
	return 0;
}



Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int x, y, z;
	scanf("%d%d", &x, &y);
	
	z = x*500;
	if(z>=y)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	
	
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <vector>
#include <map>

using namespace std;

const long long maxn = 1e5 + 1;

long long par[maxn];
long long r[maxn];
long long s[maxn];

void init(long long n)
{
    for (long long i = 0; i < n;i++)
    {
        par[i] = i;
        r[i] = 0;
        s[i] = 1;
    }
}
long long find(long long x)
{
    if(par[x] == x)
    {
        return x;
    }
    else
    {
        return par[x] = find(par[x]);
    }
}
void unite(long long x, long long y)
{
    x = find(x);
    y = find(y);
    if(x == y)
    {
        return;
    }
    if(r[x] < r[y])
    {
        s[y] = s[x] + s[y];
        par[x] = y;
    }
    else
    {
        s[x] = s[x] + s[y];
        par[y] = x;
        if(r[x] == r[y])
        {
            r[x]++;
        }
    }
}
bool same(long long x, long long y)
{
    return find(x) == find(y);
}

vector<pair<long long, long long> > pii;

int main()
{
    long long N, M;
    cin >> N >> M;
    for (long long i = 0; i < M;i++)
    {
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        pii.push_back(make_pair(a, b));
    }
    init(N);
    long long num = N * (N - 1) / 2;
    vector<long long> ans;
    for (long long i = M - 1; i >= 0; i--)
    {
        ans.push_back(num);
        long long a = pii[i].first;
        long long b = pii[i].second;
        if(same(a, b) == true)
        {
            continue;
        }
        //cout << "a" << endl;
        num -= s[par[a]] * s[par[b]];
        unite(a, b);
    }
    for (long long i = M - 1; i >= 0; i--)
    {
        cout << ans[i] << endl;
    }

    return 0;
}


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

using namespace std;

#define ll long long

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, k, s, ans;

void dfs(int x, int y, int z) {
	if (y == 0) {
		if (z == 0) ans++;
		return;
	}
	if (x > n || x > z) return;
	dfs(x + 1, y - 1, z - x);
	dfs(x + 1, y, z);
}

int main() {
	while (cin >> n >> k >> s, n) {
		ans = 0;
		dfs(1, k, s);
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 3044
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
#include<stack>
#include<map>
#include<queue>
#include<unordered_map>
#include<cmath>
#include<utility>

using ULL = unsigned long long;
using LL = long long;
using String = std::string;
using Ints = std::vector<int>;
using Doubles = std::vector<double>;
using Bools = std::vector<bool>;
using Strings = std::vector<std::string>;
using ULLs = std::vector<ULL>;
using LLs = std::vector<LL>;

// pythonのdictionary相当
template <typename T1, typename T2>
using Dict = std::unordered_map<T1,T2>;



int main(void) {
    int N;
    std::cin >> N;
    Ints res(10001, 0);

    for(int i=1;i<100;i++){
        for(int j=1;j<100;j++){
            for(int k=1;k<100;k++){
                int n = i*i+j*j+k*k+i*j+j*k+k*i;
                if(n <= 10001) res[i*i+j*j+k*k+i*j+j*k+k*i]++;
            }
        }
    }

    for(int i=1;i<=N;i++){
        std::cout << res[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
using namespace std;
#define _USE_MATH_DEFINES


int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> mata(N, vector<int>(M));
	vector<int> vecb(M, 0);
	int tmp;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> tmp;
			mata[i][j] = tmp;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		vecb[i] = tmp;
	}
	for (int i = 0; i < N; i++) {
		int c = 0;
		for (int j = 0; j < M; j++) {
			c += mata[i][j] * vecb[j];
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
const lli mod = 1e9 + 7;
lli mypow(lli x, lli y)
{
	lli res = 1;
	while(y)
	{
		if(y & 1) res = (res * x) % mod;
		x = (x * x) % mod;
		y >>= 1;
	}
	return res;
}
int main()
{
	lli x; cin >> x;
	if(x == 1) cout << 0;
	else
	{
		lli t1 = mypow(10, x);
		lli t2 = 2 * mypow(9, x) % mod;
		lli t3 = mypow(8, x);
		cout << (t1 - t2 + t3 + mod) % mod;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> h;
int cost[100005];

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        int temp;
        cin >> temp;
        h.push_back(temp);
    }

    cost[0] = 0;
    cost[1] = abs(h[0]-h[1]);
    
    for(int i = 2; i < N; ++i){   
        cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]),cost[i-2] + abs(h[i]-h[i-2]));
    }
    
    cout << cost[N-1] << endl;
    
}

Measured memory_bytes: 1144
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

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++)

#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


const int INF = 1<<29;        // 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll n,l;
    cin >> n >> l;

    ll d = (n % l);
    // cout << d << endl;

    ll d2 = l - d;
    // cout << d2 << endl;

    cout << min(d, d2) << endl;
}   

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int h[n];
  for(int i = 0;i < n;i++){
	scanf(" %d", &h[i]);
  }
  int r = 1;
  for(int i = 1;i < n;i++){
	for(int j = 0;j < i;j++){
	  if(h[i] >= h[j]){
		if(j == i - 1){
		  r++;
		}else{
		  continue;
		}
	  }else{
		break;
	  }
	}
  }
  printf("%d\n", r);
}


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

#define MAX_N 100005

int get_gcd(int a, int b) {
	int tmp = a % b;
	while (tmp > 0) {
		a = b;
		b = tmp;
		tmp = a % b;
	}
	return b;
}

int main() {
	int N;
	scanf("%d", &N);
	int A[MAX_N];
	for (int i = 0; i < N; i++) scanf("%d", A + i);
	int gcd = A[0];
	for (int i = 1; i < N; i++) gcd = get_gcd(gcd, A[i]);
	printf("%d\n", gcd);
	return 0;
}

Measured memory_bytes: 640
N = int(input())

def Harshad(n):
    s = str(n)
    sum = 0
    for i in range(len(s)):
        sum += int(s[i])

    if n%sum == 0:
        return True
    else:
        return False

D = Harshad(N)

if D:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
#define endl "\n"
using namespace std;

int main()
{
    stack <char> st;
    string str;

    cin >> str;

    for(int i = 0; i < str.length(); i ++)
    {
    	if(str[i] == '0' || str[i] == '1')
    		st.push(str[i]);
    	else if(! st.empty())
    		st.pop();
    }

    vector <char> ans;
    while(! st.empty())
    {
    	ans.push_back(st.top());
    	st.pop();
    }
    reverse(ans.begin(), ans.end());


    for(int i = 0; i < ans.size(); i ++)
    	cout << ans[i];
}

Measured memory_bytes: 256
N, M = map(int, input().split())

edges = []

for i in range(M):
    a, b, c = map(int, input().split())
    edges.append([a,b,c])

dist = [float('inf')] * (N + 1)
dist[1] = 0

for _ in range(N - 1):
    for a, b, c in edges:
        dist[b] = min(dist[b], dist[a] - c)

ans = dist[N]
for a, b, c in edges:
    dist[b] = min(dist[b], dist[a] - c)

if ans == dist[N]:
    print(-ans)
else:
    print('inf')

Measured memory_bytes: 3316
building1 = [[[0 for i in range(10)] for j in range(3)]for l in range(4)]


number_of_data = int(input())

for k in range(number_of_data):
    info = list(map(int, input().split(" ")))
    building1[info[0] - 1][info[1] - 1][info[2] - 1] += info[3]

for m in range(4):
    for floor in range(3):
        for room in range(10):
            if room != 9:
                print(" " + str(building1[m][floor][room]), end="")
            else:
                print(" " + str(building1[m][floor][room]))
    if m != 3:
        print("#" * 20)


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

typedef long long ll;

int bit_count(int x){
  int ans = 0;
  while(x>0){
    ans += x%2;
    x /= 2;
  }
  return ans;
}

int main(){
  int n=0; cin >> n;
  
  int f[n] = {};
  ll p[n][11] = {};
  
  for(int i=0; i<n; i++){
    int p = 1;
    for(int j=0; j<10; j++){
      int k; cin >> k;
      f[i] += p * k;
      p *= 2;
    }
  }
  
  for(int i=0; i<n; i++){
    for(int j=0; j<11; j++){
      cin >> p[i][j];
    }
  }
  
  ll ans = -1000000000;
  
  for(int i=1; i<1024; i++){
    ll x = 0;
    for(int j=0; j<n; j++){
      x += p[j][bit_count(i & f[j])];
    } 
    ans = ans > x? ans : x;
  }
  cout << ans << endl;
}

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

Int a, b;
Int gcd(Int x, Int y){
	while(x % y != 0){
		Int r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> a >> b;
	Int g = gcd(a, b);
	Int ans = 1;
	for(Int i=2; g>1&&i*i<=g; ++i){
		if(g % i == 0){
			++ans;
			while(g % i == 0) g /= i;
		}
	}
	if(g > 1) ++ans;
	cout << ans << "\n";
}

Measured memory_bytes: 256
def get_ac(N: int, Q: int, S: str, queries: list)->list:
    before = ''
    cum = [0] * (N+1)
    for i, c in enumerate(S):
        cum[i+1] = cum[i]
        if before + c == 'AC':
            cum[i+1] += 1
        before = c

    # print(cum)

    res = []
    for l, r in queries:
        res.append(cum[r] - cum[l])

    return res


if __name__ == "__main__":
    Q = 0
    N, Q = map(int, input().split())
    S = input()
    queries = [tuple(int(s) for s in input().split()) for _ in range(Q)]
    ans = get_ac(N, Q, S, queries)

    for a in ans:
        print(a)


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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    string ans = "No";
    if (A == B){
        if (A == C){
            ;
        } else{
            ans = "Yes";
        }
    } else if(B == C){
        if (B == A){
            ;
        } else{
            ans = "Yes";
        }
    } else if (C == A){
        if (C == B){
            ;
        } else{
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
    return 0;
}

Measured memory_bytes: 256