akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<ios>
using namespace std;
int n,m,q;
int sum[555][555];
main()
{
	cin>>n>>m>>q;
	for(int i=0;i<m;i++)
	{
		int L,R;scanf("%d%d",&L,&R);
		sum[L][R]++;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			sum[i+1][j+1]+=sum[i+1][j]+sum[i][j+1]-sum[i][j];
		}
	}
	for(int i=0;i<q;i++)
	{
		int L,R;scanf("%d%d",&L,&R);
		L--;
		printf("%d\n",sum[R][R]-sum[L][R]-sum[R][L]+sum[L][L]);
	}
}


Measured memory_bytes: 2048
A, B, H, M = map(int, input().split())

import math

atheta = (H + M/60) / 12 * 2 * math.pi

btheta = M / 60 * 2 * math.pi

theta = abs(atheta - btheta)
if theta >= math.pi:
  theta = 2*math.pi - theta


ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(theta))
print(ans)

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans;
const int maxn=1e6+7;
char s[maxn];
int main()
{
    scanf("%lld",&n);
    scanf("%s",s);
    for(int i=0;i<=n-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            ans++;
    }
    printf("%lld\n",ans);

}


Measured memory_bytes: 256
M,D = map(int,input().split())
ans = 0
for j in range(M):
  L = j + 1
  for i in range(D):
    K = i + 1
    if K > 9:
      P = str(K)
      if int(P[0]) != 1 and int(P[1]) != 1:
        if int(P[0])*int(P[1]) == L:
          
          ans += 1
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#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;


/*
           1) long long vs int overflow
           2) read question carefully
*/

#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define umapii unordered_map < int , int >
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pi>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define all(v) (v).begin(),(v).end()
#define FOR(i,a,b) for(int i = a;i <= b; i++)

#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const ll mod = 1000000007;
/*STL:
       (1) PRIORITY_QUEUE pq:
       -> priority_queue < int > pq; // max_heap
       -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap 
       -> pq.top()   --> returns the maximum or minimum element
       -> pq.push()  --> push element into the queue
       -> pq.pop()   --> remove top most element
       -> pq.empty() --> checks whether queue is empty or not



*/
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int inf = 1e9 + 7;

int main(){
    ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,k;
    cin >> n>>k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<int> dp(n + 1, inf);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j=i+1;j<=i+k;j++){
            if(j>=n)break;
            dp[j]=min(dp[j],dp[i]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<'\n';
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

bool check(vector<ll> &a, vector<ll> &b, ll k, ll ans) {
    list<pair<ll, int>> m;
    for (auto &i:b) {
        if (m.empty() || ans / i > m.back().first) {
            m.emplace_back(ans / i, 1);
        } else if (ans / i == m.back().first) {
            m.back().second++;
        }
    }
    int cur = 0, num = 0;
    auto it = begin(m);
    while (it != end(m) && cur < a.size()) {
        num += it->second;
        while (cur < a.size() && a[cur] <= it->first) {
            cur++;
        }
        if (cur < num) {
            while (cur < a.size() && cur < num) {
                k -= a[cur] - it->first;
                cur++;
            }
            if (k < 0) {
                return false;
            }
        }
        it = next(it);
    }
    return true;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    ll n = 200000, k = 1000000000;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(begin(a), end(a));
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    sort(begin(b), end(b));
    reverse(begin(b), end(b));
    ll l = 0, r = 1e12;
    while (l + 1 < r) {
        ll mid = (r + l) / 2;
        if (check(a, b, k, mid)) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    if (check(a, b, k, l)) {
        cout << l;
    } else {
        cout << r;
    }
}

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

using namespace std;

typedef long long ll;
const int MAX = 2e5;
int a[MAX + 1];
ll n, k;

bool lessThanK(ll x, ll k) {
    ll skip = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] < 0) {
            int l = -1, h = n;
            while (l + 1 < h) {
                int m = l + (h - l) / 2;
                if (1ll * a[i] * a[m] < x) {
                    h = m;
                } else {
                    l = m;
                }
            }
            skip += n - h;
        } else {
            int l = -1, h = n;
            while (l + 1 < h) {
                int m = l + (h - l) / 2;
                if (1ll * a[i] * a[m] < x) {
                    l = m;
                } else {
                    h = m;
                }
            }
            skip += h;
        }

        if (1ll * a[i] * a[i] < x) skip--;
    }

    skip /= 2;
    return skip < k;
}

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

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

    sort(a, a + n);

    ll lo = ll(-1e18);
    ll hi = ll(1e18) + 1;
    while (lo < hi) {
        ll x = lo + (hi - lo) / 2;
        if (lessThanK(x, k)) {
            lo = x + 1;
        } else {
            hi = x;
        }
    }

    cout << lo - 1;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型

// https://drken1215.hatenablog.com/entry/2019/06/15/135300

int main()
{
    int N, M;
    cin >> N >> M;
    vector<vector<int>> S(M);
    rep(i, M)
    {
        int k;
        cin >> k;
        rep(j, k)
        {
            int s;
            cin >> s;
            s--;
            S[i].push_back(s);
        }
    }
    vector<int> P(M);
    rep(i, M)
    {
        cin >> P[i];
    }

    int ans = 0;

    for (int bits = 0; bits < (1 << N); ++bits)
    {
        bool ok = true;
        for (int i = 0; i < M; i++)
        {
            int cul = 0;
            for (auto v : S[i])
            {
                if (bits & (1 << v))
                    ++cul;
            }
            if (cul % 2 != P[i])
            {
                ok = false;
            }
        }
        if (ok)
            ++ans;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define INF 1110000000

int main(){
        long long i,j,k,N,a,b,c,mina,asum=0,bsum=0,csum=0;
        cin >> N;
        long long A[N],B[N],C[N];
        for(i=0;i<N;i++){
                cin >> A[i];
        }
        for(i=0;i<N;i++){
                cin >> B[i];
        }
        for(i=0;i<N;i++){
                cin >> C[i];
        }
        sort(A,A+N);
        sort(B,B+N);
        sort(C,C+N);
        i=0;
        j=0;
        k=0;
        //for(i=0;i<N;i++)cout << A[i] << endl;
        i=0;
        while(i!=N || j!=N || k != N){
                if(i==N)a=INF;
                else a=A[i];
                if(j==N)b=INF;
                else b = B[j];
                if(k==N)c=INF;
                else c = C[k];
                mina = min(a,b);
                mina = min(c,mina);
                //cout << mina << endl;
                if(mina == c){
                        k++;
                        //if(k==N)k--;
                        csum+=bsum;
                }else if(mina == b){
                        j++;
                        //if(j==N)j--;
                        bsum+=asum;
                }else if(mina == a){
                        i++;
                        //if(i==N)i--;
                        asum++;
                }
        }
        cout << csum << endl;
        return 0;
}

Measured memory_bytes: 2560
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t A,B;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> A>>B;
	if (A > B) {
		std::swap(A, B);
	}
	if ((B - A) % 2 == 1) {
		out << "IMPOSSIBLE\n";
	}
	else {
		out << (B - A) /2 + A<<"\n";
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
using ll = long long;
const int N = 2e6 + 15;
int main(){
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	int ok = 0;
	for (int i = a; i <= b; ++i) {
		if (i % k == 0) ok = 1;
	}
	if (ok) {
		cout << "OK\n";
	}else {
		cout << "NG\n";
	}
	return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Five Antennas
            if (CanComunicate())
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }

        static bool CanComunicate()
        {
            var antennas = ReadLines(5);
            int k = int.Parse(Console.ReadLine());

            for (int i = 1; i < 5; i++)
            {
                for(int j = 0; j < i; j++)
                {
                    int distance = antennas[i] - antennas[j];

                    if (distance > k)
                    {
                        return false;
                    }
                }                
            }

            return true;
        }

        static List<int> ReadLines(int count = 0)
        {
            //[summary]コンソールの値を読み込む
            var list = new List<int>();

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string s = Console.ReadLine().TrimEnd();
                count = int.Parse(s);
            }

            for (int i = 0; i < count; i++)
            {
                string s = Console.ReadLine().TrimEnd();
                list.Add(int.Parse(s));
            }

            return list;
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {
    public static void main (String[] args) {
        Scanner scan = new Scanner(System.in);
        int m = scan.nextInt();
        String a_card = null;
        String b_card = null;
        int a_point = 0;
        int b_point = 0;

        int j = 0;
        int i = 0;

        int compare_length = 0;


        while(i < m){

            a_card = scan.next().toLowerCase();
            b_card = scan.next().toLowerCase();
            if(a_card.length() < b_card.length()){
                compare_length = a_card.length();
            }else{
                compare_length = b_card.length();
            }

            j = 0;
            while(true){
                if(a_card.charAt(j) == b_card.charAt(j) && compare_length == (j + 1)){
                    if(compare_length < a_card.length()){
                        a_point += 3;
                        break;
                    }else if(compare_length < b_card.length()){
                        b_point += 3;
                        break;
                    }
                    a_point++;
                    b_point++;
                   
                    break;
                }else if(a_card.charAt(j) == b_card.charAt(j)){

                    
                    j++;
                }else if(a_card.charAt(j) < b_card.charAt(j)){
                    b_point += 3;
     
                    break;
                }else if(a_card.charAt(j) > b_card.charAt(j)){
                    a_point += 3;
                
                    break;

                }

            }

            i++;
        }

        System.out.println(a_point + " " + b_point);

    }
}



Measured memory_bytes: 30104
from collections import deque
INFTY = 10**3
H,W = map(int,input().split())
S = [input().strip() for _ in range(H)]
cmax = 0
for x in range(H):
    for y in range(W):
        if S[x][y]==".":
            A = [[INFTY for _ in range(W)] for _ in range(H)]
            hist = {(i,j):0 for i in range(H) for j in range(W)}
            que = deque([(x,y,0)])
            A[x][y] = 0
            hist[(x,y)] = 1
            while que:
                i,j,d = que.popleft()
                if j+1<W and S[i][j+1]=="." and hist[(i,j+1)]==0:
                    A[i][j+1]=d+1
                    hist[(i,j+1)]=1
                    que.append((i,j+1,d+1))
                if i-1>=0 and S[i-1][j]=="." and hist[(i-1,j)]==0:
                    A[i-1][j]=d+1
                    hist[(i-1,j)]=1
                    que.append((i-1,j,d+1))
                if j-1>=0 and S[i][j-1]=="." and hist[(i,j-1)]==0:
                    A[i][j-1]=d+1
                    hist[(i,j-1)]=1
                    que.append((i,j-1,d+1))
                if i+1<H and S[i+1][j]=="." and hist[(i+1,j)]==0:
                    A[i+1][j]=d+1
                    hist[(i+1,j)]=1
                    que.append((i+1,j,d+1))
            cnt=0
            for i in range(H):
                for j in range(W):
                    if S[i][j]==".":
                        cnt = max(cnt,A[i][j])
            cmax = max(cmax,cnt)
print(cmax)

Measured memory_bytes: 79568
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int A,B;
  cin>>A>>B;
  if(A-2*B>0){
    cout<<A-2*B<<endl;
  }
   if(A-2*B<=0){
     cout<<0<<endl;
   }
  }
     

    

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int a,b;
  cin>>a>>b;
  if (a>b){
    for (int i(0);i<a;i++){
      cout << b;
    }
  }else{
    for (int i(0);i<b;i++){
      cout << a;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <vector>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i_, __start, __end) for(ll i_=(ll)__start; i_<(ll)__end; i_++)
#define print(_a) cout << _a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";
#define printarray2(aa, len) rep(ij,0,len) printarray(aa[ij], aa[ij].size()); print("");


int main(){
    ll n;
    cin >> n;
    print(24 + (24-n));
   
  return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main() -> None:
    n = int(next_str())
    print(("No", "Yes")[judge(n)])


def judge(n: int) -> bool:
    price_c = 4
    price_d = 7

    for c in range(0, n // price_c + 1):
        for d in range(0, n // price_d + 1):
            if c * price_c + d * price_d == n:
                return True

    return False


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int s[100000],t[100000],p[100000],o[100001],e[100001];
int main(){
	int N,M;
	cin>>N>>M;
	rep(i,N) cin>>s[i]>>t[i];
	rep(i,M) cin>>p[i];
	sort(p,p+M);
	rep(i,M-1) e[i+1]=e[i]+(i%2==0?p[i+1]-p[i]:0);
	rep(i,M-1) o[i+1]=o[i]+(i%2==1?p[i+1]-p[i]:0);
	long long ans=0;
	rep(i,N){
		if(s[i]<t[i]){
			int ss=lower_bound(p,p+M,s[i])-p,tt=lower_bound(p,p+M,t[i])-p-1;
			if(ss==tt+1){
				ans+=t[i]-s[i];
			}else{
				ans+=p[ss]-s[i];
				if(ss%2==1){
					ans+=e[tt]-e[ss];
				}else{
					ans+=o[tt]-o[ss];
				}
				if(ss%2!=tt%2) ans+=t[i]-p[tt];
			}
		}else{
			int ss=lower_bound(p,p+M,s[i])-p-1,tt=lower_bound(p,p+M,t[i])-p;
			if(ss+1==tt){
				ans+=s[i]-t[i];
			}else{
				ans+=s[i]-p[ss];
				if(ss%2==0){
					ans+=e[ss]-e[tt];
				}else{
					ans+=o[ss]-o[tt];
				}
				if(ss%2!=tt%2) ans+=p[tt]-t[i];
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

int main(){
  int x, y;
  cin >> x >> y;

  vector<vector<int>> v{{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}};
  
  for (int i=0; i<3; i++) {
    if (count(v[i].begin(), v[i].end(), x)==1 && count(v[i].begin(), v[i].end(), y)==1) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
const int MOD = 1000000007; // 計算してからmodで割る ans = (ans * a) % mod
#define int long long
template <typename T = long long > T in () { T x; cin >> x; return(x);}
// int a = in() のように使うlong long以外の型の時はstirng s = in<string>()のように型を指定する

signed main(void){
    int n, k;
    cin >> n >> k;
    vector<double> ruiseki(n + 1);
    ruiseki[0] = 0;
    REP(i, n){
        double tmp; cin >> tmp;
        ruiseki[i + 1] = ruiseki[i] + (tmp + 1) / 2; 
    }
    double ans = 0;

    REP(i, n - k + 1){
        ans = max(ans, ruiseki[i + k] - ruiseki[i]);
    }
    cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

constexpr long long INF = LLONG_MAX;
constexpr long long MOD = 1000000007;
constexpr long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//ld d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

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

    cin >> n>>m;

    cout << n*m << endl;
}


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

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

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

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

  int N = a.back();
  int mid = (N + 1) / 2;

  int d = 1e9;
  int K = 1;
  rep(i, n - 1) {
    if (abs(mid - a[i]) < d) {
      d = abs(mid - a[i]);
      K = a[i];
    }
  }
  cout << N << " " << K << endl;
}

Measured memory_bytes: 640
#include <fstream>
#include <numeric>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
 
using namespace std;
 
#define ll long long
const int N = (ll)(2e5) + 100;
 
int div_cel(int n, int k) {
    return (n + k - 1) / k;
}

vector<string> vals;

void calc(string s) {
    const int n = (int) s.size();
    if (n > 10) {
        return;
    }
    vals.push_back(s);
    bool first = false;
    if (n == 0) first = true;
    for (char c = '0';c <= '9';c ++) {
        if (first) {
            if (c == '0') continue;
            s += c;
            calc (s);
            s.pop_back();
        } else {
            // cout << vals.size() << ' ' << n - 1 << "\n";
            int cv = c - '0';
            int pv = s[n - 1] - '0';
            if (cv == pv - 1 || cv == pv + 1 || cv == pv) {
                s += c;
                calc(s);
                s.pop_back();
            }
        }
    }
}

bool cmp (string a, string c) {
    int na = (int) a.size();
    int nc = (int) c.size();
    if (na != nc) {
        return na < nc;
    }
    return a < c;
}

void solve() {
    int k;cin >>k;
    calc("");
    sort (vals.begin(), vals.end(), cmp);
    // for (int i = 0;i < 20;i ++) {
    //     cout << vals[i] << ' ';
    // }
    cout << vals[k] << " ";
}
 
 
int main() {
    solve();
    return 0;
}

// 41 59 31
// 59 41 31
// 31 41 59


Measured memory_bytes: 13936
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N],b[N],g;
vector<int> ans;
bool isprime(int x)
{
	for(int i=2;i*i<=x;++i) if(x%i==0) return false;
	return true;
}
bool check(int x)
{
	if(!isprime(x)) return false;
	memcpy(b,a,sizeof(int)*(n+3));
	for(int i=n;i>=x;--i) b[i-(x-1)]+=b[i];
	for(int i=0;i<x;++i) if(b[i]%x) return false;
	return true;
}
int main()
{
	scanf("%d",&n);
	for(int i=n;~i;--i) scanf("%d",&a[i]),g=__gcd(g,abs(a[i]));
	for(int i=2;i*i<=g;++i)
	{
		if(g%i==0&&check(i)) ans.push_back(i);
		while(g%i==0) g/=i;
	}
	if(g>1) ans.push_back(g);
	for(int i=2;i<=n;++i) if(check(i)) ans.push_back(i);
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	for(auto x:ans) printf("%d\n",x);
}


Measured memory_bytes: 384
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
std::string S;
ll Q;

int main()
{
  std::cin >> N >> S >> Q;

  rep( q, Q )
  {
    ll k;
    std::cin >> k;

    ll cntD = 0, cntM = 0, cntP = 0, ans = 0;

    rep( i, N )
    {
      if( S[i] == 'D' )
        ++cntD;
      if( S[i] == 'M' )
      {
        ++cntM;
        cntP += cntD;
      }
      if( i-k >= 0 )
      {
        if( S[i-k] == 'D' )
        {
          --cntD;
          cntP -= cntM;
        }
        if( S[i-k] == 'M' )
          --cntM;
      }

      if( S[i] == 'C' )
        ans += cntP;
    }

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

  return 0;
}

Measured memory_bytes: 1412
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>

using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
typedef struct zah{
    int y;
    int x;
    int dist;
} zah;
 
int main()
{
    int w,h;
    int ban[35][35];
    int dist[35][35];
    int kabe;
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};
    int dc[4]={3,5,7,2};
    while(1==1)
    {
        scanf("%d %d\n",&w,&h);
        if(w==0&&h==0)return 0;
        REP(i,35)REP(j,35)ban[i][j]=1;
        REP(i,35)REP(j,35)dist[i][j]=10000;
        REP(i,w)
        {
            ban[0][i]*=2;
            ban[h-1][i]*=5;
        }
        REP(j,h)
        {
            ban[j][0]*=7;
            ban[j][w-1]*=3;
        }
        REP(i,2*h-1)
        {
            if(i%2==0)
            {
                REP(j,w-1)
                {
                   scanf("%d",&kabe);
                   if(kabe==1)
                   {
                       ban[i/2][j]*=3;
                       ban[i/2][j+1]*=7;
                   } 
                }
            }
            else
            {
                REP(j,w)
                {
                    scanf("%d",&kabe);
                    if(kabe==1)
                    {
                        ban[i/2][j]*=5;
                        ban[(i+1)/2][j]*=2;
                    }
                }
            }
        }
        queue<zah> que;
        while(!que.empty())que.pop();
        zah za;
        zah zapush;
        za.x=0;
        za.y=0;
        za.dist=1;
        que.push(za);
        //printf("push (%d,%d):dist%d\n",za.y,za.x,za.dist);
        int wall;
        while(!que.empty())
        {
            za=que.front();
            que.pop();
            if(za.y==h-1&&za.x==w-1)
            {
                printf("%d\n",za.dist);
                break;
            }
            dist[za.y][za.x]=za.dist;
            wall=ban[za.y][za.x];
            REP(i,4)
            {
                if(wall%dc[i]!=0)
                {
                    //printf("$$$%d$$$\n",i);
                    if(dist[za.y+dy[i]][za.x+dx[i]]==10000)
                    {
                        //printf("jpge\n");
                        dist[za.y+dy[i]][za.x+dx[i]]=za.dist+1;
                        zapush.y=za.y+dy[i];
                        zapush.x=za.x+dx[i];
                        zapush.dist=za.dist+1;
                        que.push(zapush);
                        //printf("push (%d,%d):dist%d\n",zapush.y,zapush.x,zapush.dist);
                    }
                }
            }
        }
        if(!(za.y==h-1&&za.x==w-1))printf("0\n");
    }
    return 0;
}


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

int main(){
	int N, W, H, S, T, x, y;
	while(1){
		int temp[220][220] = {}, ans = 0, count;
		
		cin>>N;
		
		if(N == 0) break;
		
		cin>>W>>H;
		
		for(int i = 0; i < N; i++){
			cin>>x>>y;
			temp[y][x] = 1;
		}
		cin>>S>>T;
		
		for(int i = 1; i <= H; i++){
			for(int j = 1; j <= W; j++){
				count = 0;
				for(int k = 0; k < T; k++)
					for(int l = 0; l < S; l++) if(temp[i+k][j+l] == 1)count++;
				ans = max(count, ans);	
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000

using namespace std;
typedef long long ll;

int main()
{
  int N; cin >> N;
  vector<int> A(N); REP(i, N) cin >> A[i];
  sort(ALL(A));
  A.PB(-1);

  int cnt = 1, ans = 0;
  REP(i, N) {
    if (A[i] != A[i + 1]) {
      ans += cnt % 2;
      cnt = 0;
    }
    cnt++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=10000;
const ll INF=1000000010;
const ll LINF=1000000000000000010;
const int MAX=2010;
int dx[8]={0,1,0,-1,1,-1,1,-1};
int dy[8]={1,0,-1,0,1,-1,-1,1};
ll x[100010],v[100010],s1[100010],s2[100010];
int main(){
    ll n,c;cin>>n>>c;
    ll ma=0;ll sum=0;
    for(int i=1;i<=n;i++){
        cin>>x[i]>>v[i];
        sum+=v[i];
        ma=max(ma,sum-x[i]);
        s1[i]=ma;
    }
    sum=0;
    ma=0;
    for(int i=n;i>=1;i--){
        sum+=v[i];
        ma=max(ma,sum-(c-x[i]));
        s2[i]=ma;
    }
    ll ans1=s1[n];
    sum=0;
    s1[0]=0;
    for(int i=n;i>=1;i--){
        sum+=v[i];
        ll k=s1[i-1]+sum-(c-x[i])*2;
        ans1=max(ans1,k);
    }
    sum=0;
    ll ans2=s2[1];
    s2[n+1]=0;
    for(int i=1;i<n;i++){
        sum+=v[i];
        ll k=s2[i+1]+sum-x[i]*2;
        ans2=max(ans2,k);   
    }
    cout<<max(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
ll minD = INF;
ll minI = -1;

set<ll> A;

int main(void){
  ll X;
  I(X);
  I(N);

  REP(i, N) {
    ll tmp;
    I(tmp);
    A.insert(tmp);
  }

  FOR(i, -50, 150) {
    if (A.count(i) == 0) {
      ll d = abs(i - X);
      if (d < minD) {
        minD = d;
        minI = i;
      }
    }
  }

  P(minI);

}


Measured memory_bytes: 3628
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

long long h[(int)1e5+5];
long long dp[(int)1e5+5];

int main() {
	IOS
	int n, k;
	cin >> n >> k;
	for(int i=0; i<n; i++) cin >> h[i];
	dp[0] = 0;
	for(int i=1; i<n; i++) {
		long long mn = LLONG_MAX;
		for(int j=i-1; j>=i-k && j>=0; j--) {
			mn = min(mn, dp[j] + abs(h[i]-h[j]));
		}
		dp[i] = mn;
	}
	//for(int i=0; i<n; i++) cout << dp[i] << endl;
	cout << dp[n-1];
 	return 0;
}


Measured memory_bytes: 1792
read N
zyotan=$(awk "END {print(sqrt($N))}" | cut -d "." -f 1)
#echo $zyotan

A=$(seq $zyotan -1 1 | awk $(echo $N'%$1==0{print($1)}') | head -n 1)
B=$(expr $N / $A)

#echo $A $B

# $B -gt $A hence
# max(keta(A),keta(B))=keta(B)
echo -n $B | wc -c


Measured memory_bytes: 1236
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int n,k;
		scanf("%d%d",&n,&k);
		int a[n+5];
		for (int i=0 ; i<n ; i++) scanf("%d",&a[i]);
		for (int i=0 ; i<abs(n-k) ; i++)
		{
			if(a[i]<a[i+k])
			printf("Yes\n");
			else
			printf("No\n");
		}
		return 0;  
}  


Measured memory_bytes: 4576
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
def do():
    a = LIST()
    a.sort()
    if a[0]+a[1]==a[2]:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 2940
while True:
    R_0, W_0, C, R = map(int, raw_input().split())

    if R_0 == 0 and W_0 == 0 and C == 0 and R == 0:
        break

    t = max(0, C * W_0 - R_0)
    print t / R if t % R == 0 else t / R + 1



Measured memory_bytes: 4632
package main

import "fmt"

func main() {
	var X int
	fmt.Scan(&X)

	ans := nextPrime(X)
	fmt.Println(ans)
}

func nextPrime(X int) int {
	num := X
	for {
		if isPrime(num) {
			return num
		} else {
			num++
		}
	}
}

func isPrime(num int) bool {
	if num == 2 {
		return true
	}
	if num%2 == 0 {
		return false
	}

	for i := 3; i < num; i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

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

void solve(long long N) {
    if( N % 10 == 3 ){
        cout << "bon" << endl;
    }else {
        int a[] = {2, 4, 5, 7, 9};
        for(int i : a ){
            if( N % 10 == i ){
                cout << "hon" << endl;
                return;
            }
        }
        cout << "pon" << endl;
    }

}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3768
w,h = map(int,input().split())
p = list(sorted([int(input()) for i in range(w)],reverse=True))
q = list(sorted([int(input()) for i in range(h)],reverse=True))

steps = w+h
w += 1; h += 1
ret = 0
for i in range(steps):
    if w == 1 or h != 1 and p[-1] > q[-1]:
        ret += w * q.pop()
        h -= 1
    else:
        ret += h * p.pop()
        w -= 1
print(ret)


Measured memory_bytes: 12588
#include <bits/stdc++.h>
using namespace std;
string s;
stack<int> st;
int main() {
	ios_base::sync_with_stdio(false);
	cin>>s;
	for(auto i : s) 
		if(i=='T'&&!st.empty()&&st.top()=='S') st.pop();
		else st.push(i);
	cout<<st.size();
}	

	

Measured memory_bytes: 1300
using System;
using System.Linq;

namespace _0296
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int saihu = x[0] + x[1] * 5 + x[2] * 10 + x[3] * 50 + x[4] * 100 + x[5] * 500;
            if (saihu >= 1000)
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n,k;cin>>n>>k;
  vector<ll> v(n);
  for(ll i=0;i<n;i++)cin>>v[i];
  sort(v.begin(), v.end());
  ll ans=pow(10, 10);
  for(ll i=0;i<n;i++){
    if (i+k-1 >= n)break;
    ll t = v[i+k-1] - v[i];
    ans=min(ans, t);
  }
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 4008
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

//Driving an Icosahedral Rover
public class Main{

	int[][] move = {
			{5, 13, 15},
			{14, 16, 3},
			{17, 4, 12},
			
			{20, 8, 1},
			{6, 2, 18},
			{0, 19, 7},
			
			{4, 22, 11},
			{23, 9, 5},
			{10, 3, 21},
			
			{12, 7, 24},
			{8, 25, 13},
			{26, 14, 6},
			
			{9, 28, 2},
			{29, 0, 10},
			{1, 11, 27},
			
			{32, 34, 0},
			{35, 1, 30},
			{2, 31, 33},
			
			{34, 37, 4},
			{38, 5, 35},
			{3, 33, 36},
			
			{37, 40, 8},
			{41, 6, 38},
			{7, 36, 39},
			
			{40, 43, 9},
			{44, 10, 41},
			{11, 39, 42},
			
			{43, 32, 14},
			{30, 12, 44},
			{13, 42, 31},
			
			{28, 46, 16},
			{47, 17, 29},
			{15, 27, 45},
			
			{50, 20, 17},
			{18, 15, 48},
			{16, 49, 19},
			
			{53, 23, 20},
			{21, 18, 51},
			{19, 52, 22},
			
			{56, 26, 23},
			{24, 21, 54},
			{22, 55, 25},
			
			{59, 29, 26},
			{27, 24, 57},
			{25, 58, 28},
			
			{58, 50, 32},
			{48, 30, 59},
			{31, 57, 49},
			
			{46, 53, 34},
			{51, 35, 47},
			{33, 45, 52},
			
			{49, 56, 37},
			{54, 38, 50},
			{36, 48, 55},
			
			{52, 59, 40},
			{57, 41, 53},
			{39, 51, 58},
			
			{55, 47, 43},
			{45, 44, 56},
			{42, 54, 46}
	};
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int[][][] d = new int[201][201][60];
		for(int i=0;i<201;i++)for(int j=0;j<201;j++)for(int k=0;k<60;k++)d[i][j][k] = 150;
		d[100][100][0] = 0;
		Queue<int[]> q = new LinkedList<int[]>();
		q.add(new int[]{100, 100, 0});
		while(!q.isEmpty()){
			int[] V = q.poll();
			int x = V[0], y = V[1], s = V[2];
			if(d[x][y][s]==100)break;
			int nx = x+1, ny = y, ns = ((x+y)&1)==0?move[s][0]:move[s][1];
			if(0<=nx&&nx<=200&&0<=ny&&ny<=200&&d[x][y][s]+1 < d[nx][ny][ns]){
				d[nx][ny][ns] = d[x][y][s]+1; q.add(new int[]{nx, ny, ns});
			}
			nx = x-1; ny = y; ns = ((x+y)&1)==0?move[s][1]:move[s][0];
			if(0<=nx&&nx<=200&&0<=ny&&ny<=200&&d[x][y][s]+1 < d[nx][ny][ns]){
				d[nx][ny][ns] = d[x][y][s]+1; q.add(new int[]{nx, ny, ns});
			}
			nx = x; ny = ((x+y)&1)==0?(y+1):(y-1); ns = move[s][2];
			if(0<=nx&&nx<=200&&0<=ny&&ny<=200&&d[x][y][s]+1 < d[nx][ny][ns]){
				d[nx][ny][ns] = d[x][y][s]+1; q.add(new int[]{nx, ny, ns});
			}
		}
		for(;;){
			int x = sc.nextInt(), y = sc.nextInt(), N = sc.nextInt();
			if((x|y|N)==0)break;
			x+=100; y+=100;
			int k = 3*N;
			System.out.println(Math.min(d[x][y][k], Math.min(d[x][y][k+1], d[x][y][k+2])));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 31000
/* ***************************************
Author        :Scau.ion
Created Time  :2017/04/15 20:06:07 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn=100010;

int a[maxn];

int main()
{
    IOS;
    int n;
    cin>>n;
    for (int j=1;j<=n;++j)
        cin>>a[j];
    int ans=1;
    int type=0;
    for (int j=2;j<=n;++j)
    {
        if (type==0)
        {
            if (a[j]>a[j-1]) type=1;
            else if (a[j]<a[j-1]) type=-1;
        }
        else if (type==1)
        {
            if (a[j]<a[j-1])
            {
                ++ans;
                type=0;
            }
        }
        else
        {
            if (a[j]>a[j-1])
            {
                ++ans;
                type=0;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	string ans = "aaa";
	ans[0] = s1[0];
	ans[1] = s2[0];
	ans[2] = s3[0];
	for (int i = 0; i < 3; i++) {

		if (ans[i] == 'a')ans[i] = 'A';
		if (ans[i] == 'b')ans[i] = 'B';
		if (ans[i] == 'c')ans[i] = 'C';
		if (ans[i] == 'd')ans[i] = 'D';
		if (ans[i] == 'e')ans[i] = 'E';
		if (ans[i] == 'f')ans[i] = 'F';
		if (ans[i] == 'g')ans[i] = 'G';
		if (ans[i] == 'h')ans[i] = 'H';
		if (ans[i] == 'i')ans[i] = 'I';
		if (ans[i] == 'j')ans[i] = 'J';
		if (ans[i] == 'k')ans[i] = 'K';
		if (ans[i] == 'l')ans[i] = 'L';
		if (ans[i] == 'm')ans[i] = 'M';
		if (ans[i] == 'n')ans[i] = 'N';
		if (ans[i] == 'o')ans[i] = 'O';
		if (ans[i] == 'p')ans[i] = 'P';
		if (ans[i] == 'q')ans[i] = 'Q';
		if (ans[i] == 'r')ans[i] = 'R';
		if (ans[i] == 's')ans[i] = 'S';
		if (ans[i] == 't')ans[i] = 'T';
		if (ans[i] == 'u')ans[i] = 'U';
		if (ans[i] == 'v')ans[i] = 'V';
		if (ans[i] == 'w')ans[i] = 'W';
		if (ans[i] == 'x')ans[i] = 'X';
		if (ans[i] == 'y')ans[i] = 'Y';
		if (ans[i] == 'z')ans[i] = 'Z';

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e4+5;
const int md = 1e9+7;

string s; int d;
int dp[mx][2][105];

int fun(int idx, int f, int v){
    if(idx == s.size()) return v==0;

    int &ans = dp[idx][f][v];
    if(ans != -1) return ans; ans=0;

    int val = s[idx] - '0';
    int lim = f>0 ? 9 : val;
    for(int i=0; i<=lim; i++)
        ans += fun(idx+1, i!=val?1:f, (v+i)%d), ans %= md;
    return ans;
}

int main(){

    cin.tie( nullptr );
    ios_base::sync_with_stdio(0);

    cin >> s >> d;
    memset(dp, -1, sizeof dp);
    cout << (fun(0, 0, 0)-1+md)%md << "\n";

    return 0;
}


Measured memory_bytes: 12508
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define int long long
using namespace std;
using cd = complex <double>;
 
typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 1e9 + 7;//786433;//998244353;
const double Pi = acos(-1);
const int p = 510200;
 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
int a[100005], b[100005], c[100005];
int dp[100005][3];

signed main()
{
	Fastio();
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[1][0] = a[1];
	dp[1][1] = b[1];
	dp[1][2] = c[1];
	for(int i = 2; i <= n; i++)
	{
		dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
		dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
		dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
}

Measured memory_bytes: 4992
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>


static int merge(int A[], int left, int mid, int right) {
    int *l, *r;
    int i, l_i, r_i;
    int n1 = mid - left;
    int n2 = right - mid;
    int ret = 0;

    l = (int*)malloc( sizeof(int) * (n1 + 1));
    r = (int*)malloc( sizeof(int) * (n2 + 1));

    for ( i = 0; i < n1; i++ ) {
        l[i] = A[left+i];
    }
    l[i] = INT_MAX;
    for ( i = 0; i < n2; i++ ) {
        r[i] = A[mid+i];
    }
    r[i] = INT_MAX;
    
    l_i = 0;
    r_i = 0;
    for ( i = left ; i < right ; i++ ) {
        if ( l[l_i] <= r[r_i] ) {
            A[i] = l[l_i];
            l_i++;
        } else {
            A[i] = r[r_i];
            r_i++;
        }
        ret++;
    }

    free(l);
    free(r);
    
    return ret;
}


static int mergeSort(int A[], int left, int right) {
    int r=0;
    int mid;
    
    if ( left + 1 < right ) {
        mid = (left + right) / 2;

        r += mergeSort(A, left, mid);
        r += mergeSort(A, mid, right);
        r += merge(A, left, mid, right);
    }

    return r;
}

int main(int argc, char* argv[]) {
    int n, i, r;
    int S[500000];

    scanf("%d\n", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &S[i]);
    }

    r = mergeSort(S, 0, n);

    for ( i = 0; i < n; i++ ) {
        printf("%d", S[i]);
        if ( i + 1 < n ){
            printf(" ");
        }
    }
    printf("\n");
    printf("%d\n", r);

    return 0;
}



Measured memory_bytes: 6280
package main

import (
	"fmt"
)

func main() {
	// gcd(a, b, c) = gcd(gcd(a, b), c)
	var K int
	fmt.Scanf("%d", &K)

	sum := 0
	for i := 1; i <= K; i++ {
		for j := 1; j <= K; j++ {
			for k := 1; k <= K; k++ {
				sum += gcd(gcd(i, j), k)
			}
		}
	}
	fmt.Println(sum)
}

func gcd(a, b int) int {
	if a > b {
		b, a = a, b
	} else if a == b {
		return a
	}
	// b > a
	for a != 0 {
		a, b = b%a, a
	}
	return b
}


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

int d; //日数
const int z=26; //コンテスト数
vector<int> c(z); //コンテストiが開催されないペナルティ
vector<vector<int>> s; //i日目にコンテストjが開催された時の満足度

int score(vector<int> &t)
{
    int sum = 0;
    vector<int> last(z, -1); //コンテストが最後に開催された日
    for (int i = 0; i < t.size(); i++)
    {
        sum += s[i][t[i]];
        last[t[i]] = i;
        for (int j = 0; j < z; j++)
        {
            sum -= c[j] * ((i+1) - (last[j]+1));
        }
        
    }
    return sum;
}

void Main()
{
    cin >> d;
    s = vector<vector<int>>(d, vector<int>(z));
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < z; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> t;
    for (int i = 0; i < d; i++)
    {
        int tmp;
        cin >> tmp;
        t.push_back(tmp-1);
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        int d, q;
        cin >> d >> q;
        d--; q--;
        t[d] = q;
        cout << score(t) << endl;
    }

    
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(){
	int n,k,x,y,i,w=0;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k){
		for(i=0;i<k;i++)
			w=w+x;
		for(i=0;i<n-k;i++)
			w=w+y;
		printf("%d\n",w);
	}
	else{
		for(i=0;i<n;i++)
			w=w+x;
		printf("%d\n",w);
	}
	return 0;
}

Measured memory_bytes: 128
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Control.Monad

main = do
    -- n <- BS.readInt <$> BS.getLine
    -- a <- map read <$> replicateM n getLine
    [a, b] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    putStrLn $ if (a + b) `mod` 2 == 1 then "IMPOSSIBLE" else show $ (a + b) `div` 2


Measured memory_bytes: 380