akhauriyash/Code-Regression huggingface dataset:
//17571@nith.ac.in @Ankit Verma
#include <bits/stdc++.h>
#define bolt ios::sync_with_stdio(false)
#define ull unsigned long long
#define ll long long
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
using namespace std;

int main() {

/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
#endif*/

	bolt;
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s; cin >> s;
	int cnt1 = 0; int cnt2 = 0;
	for (int i = 0; i < 3; i++){
		if (s[i] == 'A') {
			cnt1++;
		} else {
			cnt2++;
		}
	}
	if (cnt1 > 0 && cnt2 > 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int a;
    cin>>a;
    int max=0;
    int count=0;
    bool flag=true;
    rep(i,a){
        count=0;
        flag=true;
        int t=i+1;
        while(flag){
            if(t%2==0){ 
                count++;
                t=t/2;
            }
            else{
                flag=false;
                if(count>=max){
                    max=count;
                }
            }
        }
    }
    int ret=1;
    rep(i,max){
        ret=ret*2;
    }
    cout<<ret<<endl;
    
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
ll rui[ohara];
ll tate[ohara];
deque<ll> ans;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    if(n==0){
        if(k==0)Cout("0 0");
        else Cout(-1);
    }
    else if(n==1){
        if(k==0)Cout("0 0 1 1");
        else Cout(-1);
    }
    else{
    cnt=2;
    rui[0]=1;
    rrep(i,1,46){
        rui[i]=cnt;
        cnt*=2;
    }
    if(k==0){
        rep(i,rui[n]){
            if(i==rui[n]-1){
                cout<<i<<" "<<i<<"\n";
            }
            else cout<<i<<" "<<i<<" ";
        }
        return 0;
    }
    tmp=k;
    while(1){
        rrrep(i,45,0){
            if(rui[i]<=tmp){
                tmp-=rui[i];
                tate[i+1]++;
                break;
            }
        }
        if(tmp==0)break;
    }
    if(rui[n]<=k)Cout(-1);
    else{
        ans.push_back(0);
        ans.push_back(k);
        ll judge=0;
        rrep(i,1,rui[n]){
            if(i==k||i==0)continue;
            ans.push_front(i);
            ans.push_back(i);
            judge=(judge xor i);
        }
        ans.push_front(0);
        ans.push_back(k);
        if(judge==k){
            rep(i,Size(ans)){
                if(i==Size(ans)-1)Cout(ans[i]);
                else cout<<ans[i]<<" ";
            }
        }
        else{
          
            Cout(-1);
        }
    }
    }
    return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const ut INF=1LL<<30;
const int SIZE=2001;
int main(){
	int N,A,B,t;
	cin >> N >>A >> B;
	int ans=0;
	REP(i,N){
		cin >> t;
		if(t<A or B<=t) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <forward_list>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// sanitize: shift + f11
// debug: shift + f9

ll eval(ll A, ll B, ll mid) {
    return floor((double)A*((double)mid/(double)B)) - A*floor((double)mid/(double)B);
}

int main()
{
    ll A, B, N;
    cin >> A >> B >> N;

    cout << eval(A, B, min(B-1, N)) << endl;
}

Measured memory_bytes: 3596
from math import sqrt

n, d = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

for i in range(n):
    for j in range(i + 1, n):
        D = 0
        for k in range(d):
            D += (X[i][k] - X[j][k]) ** 2
        if sqrt(D).is_integer():
            ans += 1
print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

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

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

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; q++)
    {
        int l, r;
        cin >> l >> r;
        r++;
        cout << cum[r] - cum[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

char C[2][3];
int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  REP(i, 2) REP(j, 3) cin >> C[i][j];

  if (C[0][0] != C[1][2] || C[0][1] != C[1][1] || C[0][2] != C[1][0]) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string A;
    cin >> A;
    ll N = A.size();
    map<char, int> mp;
    rep(i, 26){
        mp[alpha[i]] = i;
    }
    ll cnt[26];
    fill_n(cnt, 26, 0);
    rep(i, N){
        cnt[mp[A[i]]]++;
    }
    ll ans = 1 + N*(N-1)/2;
    rep(i, 26){
        ans -= cnt[i]*(cnt[i]-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;

int n, m, a, b;
int grid[N][N];

void solve() {
    cin >> n >> m >> a >> b;
    memset(grid, 0, sizeof(grid));
    for(int i = 1; i <= b; i++) {
        for(int j = 1; j <= a; j++) {
            grid[i][j] = 1;
        }
    }
    for(int i = b + 1; i <= n; i++) {
        for(int j = a + 1; j <= m; j++) {
            grid[i][j] = 1;
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cout << grid[i][j];
        }
        cout << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    solve();
}

Measured memory_bytes: 7544
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

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>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;

    vector<vector<pii> > g(n+1);

    rep(i,n-1){
        int u,v,w;
        cin >> u >> v >> w;
        g[u].emplace_back(v,w);
        g[v].emplace_back(u,w);
    }

    vector<int> dist(n+1,LINF);
    min_heap<pii> pq;
    dist[1] = 0;
    pq.emplace(0,1);

    while(!pq.empty()){
        int now,cost;
        tie(cost,now) = pq.top();
        pq.pop();
        if(cost > dist[now]) continue;
        rep(i,g[now].size()){
            int ncost,next;
            tie(next,ncost) = g[now][i];
            if(chmin(dist[next],dist[now] + ncost)){
                pq.emplace(dist[next],next);
            }
        }
    }

    reps(i,n){
        cout << ((dist[i] & 1) ? 1 : 0) << '\n';
    }

    return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int memo[110][2], done[110][2], col[110], n;
int dp(int a, int b)
{
	if (a == n-1) return b;
	if (a == n) return 0;
	if (done[a][b]) return memo[a][b];
	done[a][b] = 1;
	int ans = 1e9;
	if (col[a] == col[a+1]) 
	{
		if (!b) ans = min(dp(a+1, b)+1, dp(a+1, 1));
		else ans = dp(a+1, 0) + 1;
	}
	else
	{
		ans = dp(a+1, 0) + b;
	}
	return memo[a][b] = ans;
}
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &col[i]);
	int ans = dp(0, 0);	
	printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.util.*;

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


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
int main(){
  long long n,k;
  cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  long long result = 0L;
  
  for(int i=0;i<n;++i){
    long long currleft = 0;
    long long allleft = 0;
    for(int j=i;j<n;++j){
      if(arr[i]>arr[j]){currleft++;}
    }
    for(int j=0;j<n;++j){
      if(arr[i]>arr[j]){allleft++;}
    }
    long long tmp = (k * currleft) % mod + (k * (k-1) / 2) % mod * allleft % mod ;
    result += tmp;
    result = result % mod;
  }
  cout<<result<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define el_cucuy ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, k, w[mxn], c[mxn], dp[101][mxn];

int main(){
    el_cucuy
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> w[i] >> c[i];
    }for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= k; j ++){
            dp[i][j] = dp[i - 1][j];
            if(j >= w[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + c[i]);
        }
    }cout << dp[n][k];
    return 0;
}


Measured memory_bytes: 293120
def main():
  n = int(input())
  a = list(map(int,input().split()))
  b = list(map(int,input().split()))
  b.append(0)
  
  ans = 0
  left =0
  for i in range(n+1):
    if a[i] >= left:
      ans += left
      a[i] -= left
      
      if a[i] >= b[i]:
        ans += b[i]
        left = 0
      else:
        ans += a[i]
        left = b[i] - a[i]
    else:
      ans += a[i]
      left = b[i]
  print(ans)

if __name__ == '__main__':
  main()

Measured memory_bytes: 18476
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000



typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

int main()
{
	queue Q[20];
	char str[201];
	int i, j;
	int num;
	int h;
	int count = 0;

	while (1)
	{
		init(&Q[count]);

		scanf("%s", str);
		if (strcmp(str, "-") == 0)
			break;

		for (i = 0; i < strlen(str); i++)
		{
			enqueue(&Q[count], str[i]-'a');
		}


		scanf("%d", &num);

		for (i = 0; i < num; i++)
		{
			scanf("%d", &h);
			for (j = 0; j < h; j++)
				enqueue(&Q[count], dequeue(&Q[count]));
		}
		count++;
	}

	for (i = 0; i < count; i++)
	{
		while (!empty(&Q[i]))
			printf("%c", 'a' + dequeue(&Q[i]));

		printf("\n");
	}


	return 0;
}



Measured memory_bytes: 2112
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int n, m;
    cin >> n >> m;
    vector<int> kinds(m, 0);
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int a;
            cin >> a;
            a--;
            kinds[a]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < kinds.size(); i++){
        if(kinds[i] == n) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int N;
	int A[210];
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> A[i];

	int res = 0;
	while (true) {
		bool exist_odd = false;
		for (int i = 0; i < N; ++i) {
			if (A[i] % 2 != 0) exist_odd = true;
		}
		if (exist_odd) break;

		for (int i = 0; i < N; ++i) {
			A[i] /= 2;
		}
		++res;
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string.h>
using namespace std;
struct node
{
    int tou;
    int wei;
};

int main()
{
    int length;
    string in;
    cin>>length;
    cin>>in;
    int ans[100];
    for(int i=1;i<length;i++)
    {
        int temp=0;
        int biao[26];
        memset(biao,0,26*4);
        for(int m=0;m<i;m++)
        {
            biao[in[m]-'a']=1;
        }
        for(int n=i;n<length;n++)
        {
            if(biao[in[n]-'a']==1)
            biao[in[n]-'a']=2;
        }
        for(int c=0;c<26;c++)
        {
            if(biao[c]==2)
                temp++;
        }
        ans[i-1]=temp;
    }int step=0;
    for(int i=0;i<length-1;i++)
    {
        if(ans[i]>step)
            step=ans[i];
    }
    cout<<step<<endl;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline


def ns(): return readline().rstrip()


def ni(): return int(readline().rstrip())


def nm(): return map(int, readline().split())


def nl(): return list(map(int, readline().split()))


N = ni()
C = ns()

r_index = []
for i in range(N):
    if C[i] == "R":
        r_index.append(i)
if len(r_index) == 0 or len(r_index) == N:
    print(0)
    exit()

ans = 0
for i in range(len(r_index)):
    if r_index[i] >= len(r_index):
        ans += 1
print(ans)


Measured memory_bytes: 17228
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b[ohara], c[ohara], d, tmp, m, h, w, x, y, sum, k, q;
ll de[ohara];
map<P, ll> mp;
V g[ohara];
bool vi[ohara];

void dfs(ll now, ll dep) {
  if (vi[now]) return;
  vi[now] = true;
  de[now] = dep;
  rep(i, Size(g[now])) {
    ll to = g[now][i];
    dfs(to, dep + mp[{now, to}]);
  }
}

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

  cin >> n;
  rep(i, n - 1) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    g[a[i]].p_b(b[i]);
    g[b[i]].p_b(a[i]);
    mp[{a[i], b[i]}] = c[i];
    mp[{b[i], a[i]}] = c[i];
  }
  dfs(0LL, 0LL);
  rep(i, n) {
    if (de[i] % 2 == 0)
      Cout(0);
    else
      Cout(1);
  }
  return 0;
}

Measured memory_bytes: 54272
def lcm(x, y):
   if x > y:
       greater = x
   else:
       greater = y
 
   while(True):
       if((greater % x == 0) and (greater % y == 0)):
           lcm = greater
           break
       greater += 1
 
   return lcm
x = int(input())
if 360%x == 0:
    print(int(360/x))
else :
    print(int(lcm(360,x)/x))


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in(),M=in();
	priority_queue<ll,vector<ll>,greater<ll>> A;
	ll sum=0;
	REP(i,N){
		ll x=in<ll>();
		A.push(x);
		sum += x;
	}
	vector<pair<ll,ll>> BC(M);
	REP(i,M){
		ll B=in<ll>(),C=in<ll>();
		BC[i] = make_pair(B,C);
	}
	sort(ALL(BC),[&](pair<ll,ll>& lhs,pair<ll,ll>& rhs){return lhs.second>rhs.second;});
	REP(i,M){
		A.top();
		ll B=BC[i].first,C=BC[i].second;
		REP(j,B){
			ll D = A.top();
			if(D<C){
				sum -= D;
				A.pop();
				A.push(C);
				sum += C;
			}
			else break;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
#define int long long
	int n;
	cin >> n;
	int a[10010], b[10010];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum -= a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		sum += b[i];
	}
	bool ans = true;
	int o = 0, t = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > b[i]) {
			o += a[i] - b[i];
		}
		else {
			t += (b[i] - a[i] + 1) / 2;
		}
	}
	if (sum >= o && sum >= t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3796
def a_dividing_a_string():
    S = input()

    previous = ''
    ans = 0
    for ch in S:
        if len(previous) == 2:  # ch を分割とすれば条件を満たす
            ans += 1
            previous = ''
        elif len(previous) == 1:
            if ch == previous:  # previous + ch を分割とせねば条件を満たせない
                previous += ch
            else:
                ans += 1  # previous と ch はそれぞれで分割とすればいい
                previous = ch
        else:  # ch を分割とすれば条件を満たす (次の文字のために ch を足しておく)
            ans += 1
            previous = ch
    return ans

print(a_dividing_a_string())

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

int main(){
  long long N;
  cin>>N;
  long long A=0,B=0,C=0;
  for(long long i=0;i<N;i++){
    long long H;
    cin >> H;
    if(B<H){
      A=max(A,C);
      C=0;
    }
    else{
      C++;
    }
    B=H;
  }
  cout << max(A,C) << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(){}
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int n):n(n){}

  void init(int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

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

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    edges.emplace_back(u,v,c);
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
        res+=e.cost;
        unite(e.from,e.to);
        e.used=1;
      }
    }
    return res;
  }
};

struct Point{
  int x,y,idx,idy;
  Point(){}
  Point(int x,int y,int idx):x(x),y(y),idx(idx),idy(-1){}
  bool operator<(const Point &a)const{
    if(y!=a.y) return y>a.y;
    return x<a.x;
  }
};

const int MAX = 114514;
Point ps[MAX],bk[MAX];
int xs[MAX],ys[MAX];

void chk(int idx,int j){
  if(idx<0) return;
  int &idy=ps[j].idy;
  if(idy<0||xs[idy]<xs[idx]) idy=idx;
}

void upd(int &idx,int i){
  if(idx<0||xs[idx]<ps[i].x) idx=ps[i].idx;
}

void dfs(int l,int r){
  if(l+1==r) return;
  int m=(l+r)>>1;
  dfs(l,m);dfs(m,r);
  
  {
    int i=l,j=m,idx=-1;
    while(i<m||j<r){
      if(i==m||j==r){
        if(i==m) chk(idx,j++);
        if(j==r) upd(idx,i++);
        continue;
      }      
      ps[i].x+ps[i].y<=ps[j].x+ps[j].y?upd(idx,i++):chk(idx,j++);
    }
  }

  {
    int i=l,j=m,k=l;
    for(int i=l;i<r;i++) bk[i]=ps[i];
    while(i<m||j<r){
      if(i==m||j==r) ps[k++]=bk[(j==r?i:j)++];
      else ps[k++]=bk[(bk[i].x+bk[i].y<=bk[j].x+bk[j].y?i:j)++];
    }
  }
}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>xs[i]>>ys[i];

  using P = pair<int, int>;
  vector<P> es;

  for(int b=0;b<4;b++){
    for(int i=0;i<n;i++){
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      ps[i]=Point(xs[i],ys[i],i);
    }
    
    sort(ps,ps+n);
    dfs(0,n);

    for(int i=0;i<n;i++){   
      if(b&1) swap(xs[i],ys[i]);
      if(b&2) xs[i]*=-1;
      
      if(ps[i].idy<0) continue;
      int u=ps[i].idx,v=ps[i].idy;
      if(u>v) swap(u,v);
      es.emplace_back(u,v);      
    }
  }
  
  Kruskal<Int> ks(n);
  for(P e:es){
    int u,v;
    tie(u,v)=e;
    int c=max(abs(xs[u]-xs[v]),abs(ys[u]-ys[v]));
    ks.add_edge(u,v,c);
  }

  cout<<ks.build()<<endl;
  return 0;
}



Measured memory_bytes: 25036
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;




int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int x, a;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> x >> a;

    if(x < a) cout << 0;
    else cout << 10;

    //cin.close();
    //cout.close();
    return 0;
}


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

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

    long long bars[100000] = {0};

    long long i;
    for (i = 0; i < N; i++) {
        int c;
        cin >> bars[i];
    }
    sort(bars, bars + N, greater<long long>());

    long long first = 0;
    long long second = 0;

    for (i = 0; i < N; i++) {
      if (bars[i] == bars[i+1]) {
          if (first == 0) {
              first = bars[i];
              i++;
          } else {
              second = bars[i];
              cout << first * second << endl;
              return 0;
          }
      }
    }

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


Measured memory_bytes: 1024
// C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N) scanf("%d", &A[i]);
	sort(all(A));
	int ans = 0;
	int count = 1;
	rp(i, 0, N-1)
		if(A[i] == A[i+1]) count++;
		else{
			if(count&1) ans++;
			count = 1;
		}
	if(count&1) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    ll h, w;
    cin >> h >> w;

    ll ans;
    if(h == 1 || w == 1) {
        ans = 1;
    } else {
        ans = (h * w + 1) / 2;
    }

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


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<double> A(N); for(auto& in:A) cin >> in;

    vector<ll> A10(N);
    for(int i = 0; i < N;i++){
        A10[i] = llround(A[i]*1000000000LL);
    }
    vector<ll> two_cnt(N),five_cnt(N);
    for(int i = 0; i < N;i++){
        while(A10[i]%2 == 0){
            two_cnt[i]++;
            A10[i]/=2;
        }
        while(A10[i]%5 == 0){
            five_cnt[i]++;
            A10[i]/=5;
        }
    }

//    cout << two_cnt << endl;
//    cout << five_cnt << endl;

    vector<pll> ps(N);
    for(int i = 0; i < N;i++){
        ps[i] = make_pair(two_cnt[i],five_cnt[i]);
    }
    sort(ps.begin(),ps.end());

    int r = N-1;

    vector<int> F(100);
    // cout << ps << endl;
    for(int l = 0; l < N;l++){
        while(ps[l].first + ps[r].first >= 18 && r >= 0){
            F[ps[r].second]++;
            r--;
        }

        for(int i = 0; i < 100;i++){
            if(ps[l].second + i >= 18){
                res += F[i];
            }
        }

        if(l > r){
            if(ps[l].first*2 >= 18 && ps[l].second*2 >= 18){
                res--;
            }
        }
    }
    res /= 2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 12744
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#include<iomanip>
using namespace std;

int main()
{
	int n;cin>>n;
	int a[501];
	pair<int,int> q[500];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		q[i-1]=make_pair(a[i],i);
	}
	sort(q,q+n);
	int s[250010];
	memset(s,-1,sizeof(s));
	int l=0,r=n*n-1;
	for(int i=1;i<=n;i++)
	{
		s[a[i]-1]=i;
	}
	for(int i=0;i<n;i++)
	{
		int u=q[i].second;
		for(int c=1;c<u&&l<n*n;)
		{
			while(s[l]!=-1&&l<n*n)l++;
			if(l==n*n)
			{
				cout<<"No"<<endl;
				return 0;
			}
			s[l++]=u;
			c++;
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		int u=q[i].second;
		for(int c=0;c<n-u&&r>=0;)
		{
			while(s[r]!=-1&&r>=0)r--;
			if(r<0)
			{
				cout<<"No"<<endl;
				return 0;
			}
			s[r--]=u;
			c++;
		}
	}
	bool flag=true;
	int p[501][501];
	memset(p,-1,sizeof(p));
	int cou[501];
	memset(cou,0,sizeof(cou));
	for(int i=0;i<n*n;i++)
	{
		if(s[i]!=-1)p[s[i]][cou[s[i]]++]=i;
	}
	for(int i=1;i<=n;i++)
	{
		if(p[i][i-1]!=a[i]-1)flag=false;
		if(p[i][n-1]==-1)flag=false;
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
		for(int i=0;i<n*n;i++)cout<<s[i]<<(i==n*n-1?"\n":" ");
	}
	else cout<<"No"<<endl;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <set>

using namespace std;

typedef long long int ll;

const ll MOD = 1000000007;

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

  int N, Q;
  cin >> N >> Q;
  vector<set<int> > edge(N);
  for (int i = 0; i < N-1; i++) {
    int a, b;
    cin >> a >> b;
    edge[a-1].insert(b-1);
    edge[b-1].insert(a-1);
  }
  vector<pair<int, ll> > op;
  for (int i = 0; i < Q; i++) {
    int p;
    ll x;
    cin >> p >> x;
    op.emplace_back(p-1, x);
  }

  vector<ll> placement(N);
  for (auto &x: op) {
    placement[x.first] += x.second;
  }

  stack<pair<int, ll> > st;
  vector<ll> result(N);
  vector<bool> visited(N);
  st.emplace(0, 0);
  while(!st.empty()) {
    auto now = st.top();
    st.pop();
    if (visited[now.first]) continue;
    visited[now.first] = true;
    ll cost = now.second + placement[now.first];
    result[now.first] = cost;
    for (auto &y: edge[now.first]) {
      st.emplace(y, cost);
    }
  }

  for (int i = 0; i < N; i++) {
    cout << result[i];
    if (i < N-1) cout << " ";
    else cout << endl;
  }

  return 0;
}


Measured memory_bytes: 40044
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        s: chars,
    }
    for i in 0..s.len() {
        let acc= ((s[i] as u8 + n as u8 - b'A') % 26 + b'A') as char;
        print!("{}", acc)
    }
    println!("");
}


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

using namespace std;
using ll = long long int;

int main()
{
    string s;
    int i,j,len;
    cin>>s;
    len=s.length();
    int cnt=0;
    for(i=0; i<len; i++)
    {
        if(s[i]=='o') cnt++;
    }
    int rem=15-len;
    if(cnt+rem>=8)
    {
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}


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

int main(void) {
  string s;
  cin >> s;
  int ret = 0;
  for (int i = 0; i < s.size(); i++) {
    for (int j = i + 1; j <= s.size(); j++) {
      int cnt = 0;
      for (int k = i; k < j; k++) {
        if (s[k] == 'A' || s[k] == 'G' || s[k] == 'T' || s[k] == 'C') {
          cnt++;
        } else break;
      }
      ret = max(ret, cnt);
    }
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

const ll mod = (ll)1e9 + 7;
template<ll MOD>struct Mint {
  typedef const Mint&T;
  ll x = 0;
  Mint() {}
  Mint(ll a) { x = a % MOD; if (x < 0) x += MOD; }
  Mint&operator+=(T a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
  Mint&operator-=(T a) { if ((x += MOD - a.x) >= MOD) x -= MOD; return *this; }
  Mint&operator*=(T a) { x = x * a.x % MOD; return *this; }
  Mint&operator/=(T a) { return *this *= a.Pow(MOD - 2); }
  Mint operator+(T a)const { return Mint(*this) += a; }
  Mint operator-(T a)const { return Mint(*this) -= a; }
  Mint operator*(T a)const { return Mint(*this) *= a; }
  Mint operator/(T a)const { return Mint(*this) /= a; }
  bool operator<(T a)const { return x < a.x; }
  bool operator==(T a)const { return x == a.x; }
  Mint Pow(ll k)const {
    if (k == 0) return 1;
    Mint t = Pow(k / 2);
    return t *= (k & 1) ? t * *this : t;
  }
};
template<ll MOD>istream&operator >> (istream&i, Mint<MOD>&a) { return i >> a.x; }
template<ll MOD>ostream&operator<<(ostream&o, const Mint<MOD>&a) { return o << a.x; }
typedef Mint<mod>mint;

template<ll MOD = mod>Mint<MOD> CombMod(int n, int r) {
  Mint<MOD> a = 1, b = 1;
  rep(i, r) { a *= (n - i); }
  rep(i, 2, r + 1) { b *= i; }
  err(a, b);
  return a / b;
}

void Calc() {

  var(int, n, m);

  if (abs(n - m) > 1) {
    cout << (0) << endl;
    return;
  }
  mint a = 1;
  mint b = 1;
  rep(i, n) a *= i + 1;
  rep(i, m) b *= i + 1;
  err(a, b);
  if (n == m) {
    a *= 2;
  }
  cout << (a * b) << endl;


}


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

S = input()

add = [0] * (len(S)+1)

for i in range(N):
    if i==0:
        continue
    s = S[i]
    add[i] += add[i-1]
    if s == 'C':
        if S[i-1] == 'A':
            add[i] += 1

ret = []

for i in range(Q):
    l,r = map(int,input().split())
    l -= 1
    r -= 1
    
    ans = add[r] - add[l]

    ret.append(ans)

for r in ret:
    print(r)



Measured memory_bytes: 58584
/////////////////////////////////////////////////////////
//
//  c/temp.cpp file
//  Last Updated: 2018-10-23 ...Maybe
//
//    I hope you adding this code to the setting file
//    alias g++='g++ -std=c++1y -DDEBUG_LOCAL'
//
/////////////////////////////////////////////////////////

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _REP(i,n) REAP(i,0,n)
#define REAP(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(...) _overload3(__VA_ARGS__,REAP,_REP,)(__VA_ARGS__)

#define _REPR(i,n) REAPR(i,n,0)
#define REAPR(i,a,b) for(int i=int(a-1);i>=int(b);--i)
#define REPR(...) _overload3(__VA_ARGS__,REAPR,_REPR,)(__VA_ARGS__)

#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()

#define coutALL(a) {int loop_coutALL=0;for(auto e:a) cout<<(loop_coutALL++?" ":"")<<e; cout<<endl;}

#define coutYN(a) cout<<((a)?"YES":"NO")<<endl;
#define coutYn(a) cout<<((a)?"Yes":"No")<<endl;
#define coutyn(a) cout<<((a)?"yes":"no")<<endl;

#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)

const int INF=1145141919;
//const long long INF=114514191911451419;
const int MOD=(int)1e9+7;
const double EPS=1e-12;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
//const int dx[]={-1,-1,-1,0,1,1,1,0},dy[]={-1,0,1,1,1,0,-1,-1};

using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;

typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;

typedef long long ll;

template<typename T> istream &operator >> (istream &is, vector<T> &v){for(T &x:v) is>>x;return is;}
template<typename T> ostream &operator << (ostream &os, vector<T> &v){int i=0;for(T &x:v) os<<(i++?" ":"")<<x;return os;}

ll rev(ll n){ll x=0;for(;n>0;){x=x*10+n%10;n/=10;}return x;}

ll upper(ll n,ll m){return (n+m-1)/m;};
ll rounding(ll n){return (long double)n+0.5;};

bool inG(ll x,ll n){return 0<=x && x<n;}
bool outG(ll x,ll n){return x<0 || n<=x;}

inline int qp(int a,ll b){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
inline int qp(int a,ll b,int mo){if(!b)return 1;int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

inline ll fac(ll k,ll n){ll a=1;for(int i=0;i<n;i++)a*=k--;return a;}
inline ll fac(ll k,ll n,int mo){ll a=1;for(int i=0;i<n;i++)a*=k--,a%=mo;return a;}

inline int dsum(ll n){int a=0;for(;n;n/=10)a+=n%10;return a;}

struct Arithmetic{Arithmetic(){cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);}};

//#define DEBUG_LOCAL

#ifdef DEBUG_LOCAL
template<typename T> void deb(T a){cerr<<"deb: "<<a<<"です"<<endl;}
#define debl {cerr<<"debug: "<<__LINE__<<"行目だ"<<endl;}
void what_cr(){cout<<__GCC_ATOMIC_CHAR16_T_LOCK_FREE<<" ←？"<<endl;}
//ori_func S

//ori_func E
#else
template<typename T>void deb(T a){}
#define debl
void what_cr(){}void t_t(){}
#endif

signed main(){

  Arithmetic Exception;

  double a,b;
  cin>>a>>b;

  cout<<a/b<<endl;

  return 0;

}


Measured memory_bytes: 256
/* 
Rohit645
Rohit Kumar 
*/

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

using ll = long long;
using db = double;
using pll = pair < ll, ll >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std :: 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...);
}
#else
#define trace(...)
#endif

#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end() 
#define fastIo() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;

ll n;
// vector <ll> h, dp;
vector <ll> h(N), dp(N, -1);
ll solve(ll i);

int main() {
	cin >> n;
	for(ll i = 0; i < n; i++) {
		cin >> h[i];
	} 
	cout << solve(0) << endl;
	return 0;
}
ll solve(ll i) {
	ll &ans = dp[i];
	if (ans != -1) {
		return ans;
		
	}
	ans = INF;
	if (i >= n) {
		return ans;
	} else if (i == n - 1) {
		ans = 0;
		return ans;
	}
	ans = min(abs(h[i]-h[i+1])+solve(i+1), abs(h[i]-h[i+2])+solve(i+2));
	return ans;
}


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

int main()
{
  int n, k, res[1010];
  cin >> n >> k;
  for (int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;
    a = min(a, n - a + 1);
    b = min(b, n - b + 1);
    res[i] = min(a, b);
  }

  for (int i = 0; i < k; i++){
    if (res[i] % 3 == 0) res[i] = 3;
    else res[i] %= 3;
    cout << res[i] << "\n";
  }
}

Measured memory_bytes: 3044
#include <stdio.h>
#define N 300005
int main(int argc, char *argv[])
{
	long long H,W,m,count=0,dount,i,r=0,c=0;
	scanf("%lld%lld%lld",&H,&W,&m);
	long long h[N],w[N],row[N]={0},col[N]={0};
	long long rmax=-1,cmax=-1;
	for(i=0;i<m;i++){
		scanf("%lld%lld",&h[i],&w[i]);
		row[h[i]]++;
		col[w[i]]++;
		if(row[h[i]]>rmax)
			rmax=row[h[i]];
		if(col[w[i]]>cmax)
			cmax=col[w[i]];
	}
	for(i=1;i<=H;i++)
		if(row[i]==rmax)r++;
	for(i=1;i<=W;i++)
		if(col[i]==cmax)c++;
	dount=r*c;
	for(i=0;i<m;i++)
	if(row[h[i]]==rmax&&col[w[i]]==cmax)	count++;
	if(count>=dount)
		printf("%lld\n",rmax+cmax-1);
	else
		printf("%lld\n",rmax+cmax);
}

Measured memory_bytes: 11112
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int A, B;
	cin >> A >> B;

	int ans = max(A, B);
	if (A > B)A--;
	else B--;

	ans+= max(A, B);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256