akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string str;
    cin >> str;
    if(str == "AAA" || str == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

using namespace std;

bool test (double x1, double y1, double x2, double y2) {
    return x1 * y2 == x2 * y1;
}

int main (void) {
    int n;
    cin >> n;
    while (n--) {
        double x1, x2, x3, x4, y1, y2, y3, y4;
        cin >> x1; cin >> y1;
        cin >> x2; cin >> y2;
        cin >> x3; cin >> y3;
        cin >> x4; cin >> y4;
        if (test(x1 - x2, y1 - y2, x3 - x4, y3 - y4)) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1224
#include<cstdio>
int main() {
	int h,w,n,p,ans;
	scanf("%d\n%d\n%d",&h,&w,&n);
	if (h>w) p=h; else p=w;
	if (n%p) ans=n/p+1; else ans=n/p;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) std::cerr<< #x <<": "<<x<<"\n"
#define debug2(x,y) std::cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<"\n"
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  string s;
  cin >> s;
  if (s[0] != 'A') {
    printf("WA\n");
    return 0;
  }
  int l = s.length();
  int cnt = 0;
  FOR (i, 2, l-1) {
    if (s[i] == 'C') {
      cnt += 1;
    }
  }
  if (cnt != 1) {
    printf("WA\n");
    return 0;
  }
  cnt = 0;
  rep (i, l) {
    if ('a' <= s[i] && s[i] <= 'z') {
      cnt += 1;
    }
  }
  if (cnt != l-2) {
    printf("WA\n");
    return 0;
  }
  printf("AC\n");

  return 0;
}


Measured memory_bytes: 888
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int A = sc.nextInt();
   int B = sc.nextInt();
   
   int digitsum = 0;
   int tmp;
   int ans = 0;
   for(int k = 1;k<=N;k++)
   {
    digitsum=0;
    tmp = k;
    for(int i = 0;i<6;i++)
    {
      digitsum += tmp%10;
      tmp = tmp/10;
      if(tmp==0) break;
    }
    if(digitsum>=A&&digitsum<=B) ans+=k;
   }
   System.out.println(ans);
 }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using mat = vector<vector<ll>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  int Ma,Mb; cin >>Ma >>Mb;
  vector<int> a(N),b(N),c(N); rep(i, N) cin >>a[i] >>b[i] >>c[i];
  vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(401, vector<int>(401, inf)));
  dp[0][0][0] = 0;
  // dp[i][aa][bb] := i番目までの薬品を使ってタイプA,Bの合計が各々aa,bbのときの、費用の最小値
  for (int i=0; i<N; i++){
    for (int j=0; j<=400; j++){
      for (int k=0; k<=400; k++){
        if (dp[i][j][k] == inf) continue;
        chmin(dp[i+1][j][k], dp[i][j][k]);
        chmin(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k] + c[i]);
      }
    }
  }
  int res = inf;
  for (int i=0; i<=N; i++){
    for (int j=0; j<=400; j++){
      for (int k=0; k<=400; k++){
        if (j*Mb-k*Ma != 0) continue;
        if (i==0 || j==0 || k==0) continue;
        chmin(res, dp[i][j][k]);
      }
    }
  }
  res = res == inf ? -1 : res;
  cout <<res <<endl;
}


Measured memory_bytes: 27264
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	int setsX = (N + A - 1) / A;
	int setsY = (N + C - 1) / C;
	cout << min(B * setsX, D * setsY) << endl;
	return 0;
}


Measured memory_bytes: 3092
program falling_asleep
  implicit none
  integer :: n, t(50) = 0, i, m = 0
  character(100) :: s(50) = "", x
  logical :: sleeping = .false.
  read(*,*) n
  do i = 1, n
    read(*,*) s(i), t(i)
  end do
  read(*,*) x
  do i = 1, n
    if (sleeping) m = m+t(i)
    if (s(i) == x) sleeping = .true.
  end do
  write(*,'(i0)') m
end program falling_asleep

Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, first, last) for (int i = (first); i < (last); ++i)
#define REP(i, n) FOR(i, 0, n)
#define CLR(a) memset((a), 0, sizeof(a))
#define DUMP(x) std::cerr << #x << " = " << (x) << std::endl;

inline int to_int(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string to_string(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

typedef unsigned long long ull;
typedef unsigned long ul;

void print(const vector<string>& field) {
  REP(i,field.size()){
    cout<<field[i]<<endl;
  }
}

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

  vector<string> field(n);
  vector<string> ans;
  REP(i,n) cin>>field[i];
  ans=field;

  // print(field);

  REP(i,n) {
    REP(j,m) {
      if(field[i][j]!='.')continue;
      int count=0;
      for(int k=max(0,i-1);k<=min(i+1,n-1);k++) {
        for(int l=max(0,j-1);l<=min(j+1,m-1);l++) {
          if(field[k][l] == '#') count++;
        }
      }
      ans[i][j] = (char)('0' + count);
    }
  }

  print(ans);

      return 0;
}


Measured memory_bytes: 256
// atcoder/abc123/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b, c, d, e, k;
  while (cin >> a >> b >> c >> d >> e >> k) {
    vector<int> v({a, b, c, d, e});
    cout << (v.back() - v.front() <= k ? "Yay!" : ":(") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
def resolve():
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b, c = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    m = n
    sumM = 0
    while m >= 1:
        sumM += (m % 10)
        m = m // 10
#        print(m)
#    sumM += m
#    print(sumM)

    if n % sumM == 0:
        print("Yes")
    else:
        print("No")
resolve()

Measured memory_bytes: 38256
N=int(input())
D=list(map(int,input().split()))
M=int(input())
T=list(map(int,input().split()))

from collections import Counter

a=Counter(D)
b=Counter(T)

for keys in b:
  if keys not in a:
    print("NO")
    break
  else:
    if b[keys]>a[keys]:
      print("NO")
      break
else:
  print("YES")

Measured memory_bytes: 56800
#include <iostream>

using namespace std;

int c[2001] = {0};
int d[4001] = {0};

void compute(void){

  for( int i = 0 ; i <= 1000 ; i++ ){
    for( int j = 0 ; j <= 1000 ; j++ ){
      c[i+j]++;  // a + b = c の組み合わせがいくるあるか
    }
  }
  for( int i = 0 ; i <= 2000 ; i++ ){
    for( int j = 0 ; j <= 2000 ; j++ ){
      d[i+j] += c[i]*c[j];
    }
  }
}

int main(void){

  compute();

  int n;
  while( cin >> n ){
    cout << d[n] << endl;
  }
  return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<end
#define cout(n) cout<<fixed<<setprecision(n)
int main(){
  ll N=1e4+1;
  vector<ll> v(N);
  ll inst;
  FOR(i,0,N){
    inst=i;
    FOR(j,0,5){
      v[i]+=inst%10;
      inst/=10;
    }
  }

  ll X,A,B;
  cin>>X>>A>>B;
  ll res=0;
  FOR(i,1,X+1){
    if(A<=v[i]&&v[i]<=B) res+=i;
  }
  cout<<res<<endl;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BBounding solver = new BBounding();
        solver.solve(1, in, out);
        out.close();
    }

    static class BBounding {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int x = in.nextInt();
            int[] l = new int[n + 1];
            for (int i = 0; i < n; i++) {
                l[i] = in.nextInt();
            }
            int[] d = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                d[i] = d[i - 1] + l[i - 1];
            }
            int count = 0;
            for (int i = 0; i <= n; i++) {
                if (d[i] <= x) {
                    count++;
                }
            }
            out.println(count);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



Measured memory_bytes: 21460
lines = $stdin.read
array = lines.split("\n")
N,M = array[0].split(" ").map(&:to_i)
MOD = 1_000_000_007

def trial_division_sqrt(n)
  prime_count = {}

  for i in 2..(Math.sqrt(n).to_i+2)
    while n%i==0
      n /= i
      prime_count[i] = 0 unless prime_count.has_key?(i)
      prime_count[i] += 1
    end
  end
  prime_count[n] = 0 unless prime_count.has_key?(n)
  prime_count[n] += 1 if n>1
  prime_count
end

class Combination
  def initialize
    @fact = (1..10**6).to_a
    @fact.each_with_index do |e, idx|
      @fact[idx] = @fact[idx] * @fact[idx-1] % MOD if idx > 0
    end
  end

  def choose(n, r)
    return 0 if not (0 <= r and r <= n)
    return 1 if r == 0 or r == n
    fact(n) * inverse( fact(r) * fact(n-r) % MOD ) % MOD
  end

  def homogeneous(n, r)
    choose(n+r-1, r)
  end

  def fact(n)
    @fact[n-1]
  end

  def inverse(x)
    pow(x, MOD-2)
  end

  def pow(x, n)
    ans = 1
    while n > 0
      ans = ans * x % MOD if n.odd?
      x = x * x % MOD
      n >>= 1
    end
    ans
  end
end

@comb = Combination.new
ans = 1
trial_division_sqrt(M).each_with_index do |d, idx|
  k,v = d
  ans *= @comb.homogeneous(N, v) if d!=0
end
puts ans % MOD

Measured memory_bytes: 11900
N=int(input())
if N==1:
    print(0)
    exit(0)

MOD=10**9+7

a=1
b=1
c=1
for i in range(N):
    a=(a*10)%MOD
    b=(b*9)%MOD
    c=(c*8)%MOD

b*=2%MOD
if a+b-c>=0:
    print((a-b+c)%MOD)
else:
    print((a-b+c+MOD)%MOD)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
  int n;
  int count=1;//d[0]の分
  cin>>n;
  vector<int>d(n);
  rep(i,n){cin>>d[i];}
  sort(d.rbegin(),d.rend());
  for(int i=1;i<n;i++){
    if(d[i-1]==d[i])
      continue;
    else{
    count++;}
  }
   cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MAXN 111111
#define ll long long
using namespace std;

vector<pair<int,int>> edges[MAXN+2];
ll dist_from_rt[MAXN+2];

bool dfs(int u, ll currd) {
    
    if (dist_from_rt[u] != -1) {
        if (currd != dist_from_rt[u]) {
            return false;
        }
        return true;
    }
    
    dist_from_rt[u]=currd;
    
    for(pair<int,int> vd : edges[u]) {
        int v = vd.first;
        int d = vd.second;
        
        if (!dfs(v, currd+d))
            return false;
    }
    
    return true;
}

int indegree[MAXN+2];

bool Solve(int N) {
    
    for(int v=1;v<=N;v++)
        indegree[v]=0;
    
    for(int u=1;u<=N;u++) {
        for(pair<int,int> vd : edges[u]) {
            int v = vd.first;
            indegree[v]++;
        }
    }
    vector<int> sts;

    for(int u=1;u<=N;u++)
        if (indegree[u]==0)
            sts.push_back(u);
    
    if (sts.empty())
        return false;
    
    
    for(int u=1;u<=N;u++)
        dist_from_rt[u]=-1;
    
    for(int u : sts) {
        
        if (!dfs(u,0))
            return false;
    }
    
    for(int u=1;u<=N;u++)
        if (dist_from_rt[u]==-1)
            return false;
    
    return true;
}

int main() {
    int N,M;
    cin>>N>>M;
    
    for(int i=1;i<=M;i++) {
        int L,R,D;
        cin>>L>>R>>D;
        edges[L].push_back({R,D});
    }
    
    if (Solve(N)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    
    
    
    
}

Measured memory_bytes: 10240
#include<bits/stdc++.h>
#define ll long long int
#define f first
#define s second
#define pb push_back
#define PII pair<ll,ll>
ll const MOD = 1000000007;
ll const N = 1000005;
ll const LN = 20;
ll const inf = 8e18;
using namespace std;

ll n, m, a[N];

vector<ll>v[N];
vector<ll>topo;
ll vis[N];
void dfs (ll u)
{
	vis[u] = 1;
	for (auto w : v[u])
	{
		if (!vis[w])
		{ dfs (w); }
	}
	topo.pb (u);
}
int main()
{
	ios::sync_with_stdio (false);
	cin.tie (NULL);
	string str;
	cin >> str;
	ll n = str.size();
	for (ll i = 0; i < n; i++)
	{
		if (str[i] == '>')
		{
			v[i].pb (i + 1);
		}
		else
		{
			v[i + 1].pb (i);
		}
	}
	for (ll i = 0; i <= n; i++)
	{
		if (!vis[i]) { dfs (i); }
	}
	for (auto u : topo)
	{
		for (auto w : v[u])
		{
			a[u] = max (a[u], a[w] + 1);
		}
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++)
	{ ans += a[i]; }
	cout << ans;
	return 0;
}


Measured memory_bytes: 78992
#include<iostream>
#include<cmath>

using namespace std;

using ll = long long;

int main() {
    ll N,k,now=0;
    cin >> N >> k;
    ll step;
    ll mod, div;
    ll tmp;
    for(;;){
        N--;
        if(N==0)break;

        div = now/k;
        step = div + 1;
        tmp = step*k;
        mod = now%k;
        while(now+step >= tmp){
            step += (now+step-tmp)/k + 1;
            tmp = step*k;
        }
        now += step;
    }
    cout << now << endl;
    return 0;
}



Measured memory_bytes: 3088
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    return 800 * N - 200 * (N // 15)


print(solve())


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,y,res,diff_xy;
void frac(int single, int half){
  if(single>half*2){
    res=abs(diff_xy)*2*half;
  }else{
    res=abs(diff_xy)*single;
  }
}
int main(){
  scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
  if(0<(c-a)+(c-b)){
    res=a*x+b*y;
  }else{
    diff_xy=x-y;
    if(diff_xy>0){
      frac(a,c);
      x-=diff_xy;
    }else if(diff_xy<0){
      frac(b,c);
    }
    res+=c*2*x;
  }
  printf("%d\n", res);
}

Measured memory_bytes: 256
n,m,q=map(int,input().split())
t=[[0]*(1+n) for _ in range(1+n)]
for i in range(m):
    l,r=map(int,input().split())
    t[l][r]+=1
for i in range(n):
    for j in range(n+1):
        t[i+1][j]+=t[i][j]
for i in range(n+1):
    for j in range(n):
        t[i][j+1]+=t[i][j]

for i in range(q):
    p,q=map(int,input().split())
    print(t[q][q]-t[q][p-1]-t[p-1][q]+t[p-1][p-1])

Measured memory_bytes: 14828
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    int a,b;
    cin>>a>>b;
    int ans=max(a,b)*2-1;
    if(a==b) ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  long long n, x;
  cin >> n >> x;
  long long ans = 0, now = 0;
  for(int i = 0; i < n; i++){
    long long a;
    cin >> a;
    long long dis = max((long long)0, now + a - x);
    ans += dis;
    now = a - dis;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3644
a,b,c,d = map(int,input().split())
# if d >= b:
#   if b - a -c < 0:
#     print(0)
#   else:
#     print(b - a - c)
# else:
#   if d
ans = 0
al = range(a,b + 1)
bo = range(c,d + 1)
for l in al:
  if l in bo:
    ans += 1
if ans > 0:
  print(ans - 1)
else:
  print(0)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        String u = ns();
        String d = ns();

        int i = 0;
        int ans = 1;
        int prev = 0;
        if(u.charAt(0) == d.charAt(0)){
            ans = 3;
            i=1;
            prev = 0;
        }else{
            ans = 6;
            i = 2;
            prev = 1;
        }
        while(i<N){
            if(prev == 0 && u.charAt(i) == d.charAt(i)){
                ans = mul(ans,2);
                i++;
                prev = 0;
            }else if(prev==0 && u.charAt(i) != d.charAt(i)){
                ans = mul(ans,2);
                i+= 2;
                prev = 1;
            }else if(prev == 1 && u.charAt(i) == d.charAt(i)){
                ans = ans;
                i++;
                prev = 0;
            }else{
                ans = mul(ans,3);
                i+=2;
                prev=1;
            }
        }
 
        out.println(ans);
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Measured memory_bytes: 33060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool CHMAX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool CHMIN(T &l,const T &r){return l>r?l=r,1:0;}

ll MOD = 1000000007;

function<void(int,int)> tensi_no_3p=[&](int v,int d){
};

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	vint data(3);
	rep(i,3) data[i] = in();
	sort(data.begin(), data.end());
	vint data2 = data;
	int ans1 = 0;
	rep(i,3)if(data[i] % 2 == 0) ans1++, data[i]--;
	ans1 += (data[2] - data[0]) / 2;
	ans1 += (data[2] - data[1]) / 2;
	int ans2 = 0;
	rep(i, 3) if(data2[i] % 2) ans2++, data2[i]--;
	ans2 += (data2[2] - data2[0]) / 2;
	ans2 += (data2[2] - data2[1]) / 2;
	pr(ans1);
	pr(ans2);
	cout << min(ans1, ans2) << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int K = scn.nextInt();
		scn.nextLine();
		ArrayList<Integer> Inv = new ArrayList<Integer>();
		boolean is1 = true;
		int seq = 0;
		char[] str = scn.nextLine().toCharArray();
		for (int i = 0; i < N; i++) {
			char ch = str[i];
			if (is1) {
				if (ch == '0') {
					Inv.add(seq);
					seq = 1;
					is1 = false;
				} else {
					seq++;
				}
			} else {
				if (ch == '1') {
					Inv.add(seq);
					seq = 1;
					is1 = true;
				} else {
					seq++;
				}
			}
		}
		if (is1) {
			Inv.add(seq);
		} else {
			Inv.add(seq);
			Inv.add(0);
		}

		int L = Inv.size();
		int[] Lsum = new int[L + 1];
		for (int i = 0; i < L; i++) {
			Lsum[i + 1] = Lsum[i] + Inv.get(i);
		}
		int ans = 0;
		if (2 * K + 1 >= L) {
			ans = Lsum[L];
		} else {
			for (int i = 0; i < L; i += 2) {
				int r = Math.min(L-1, i + 2*K);
				ans = Math.max(ans, Lsum[r+1] - Lsum[i]);
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 28100
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ld = long double;

int main() {
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
	ll s, d = 1e9;
    cin >> s;
    cout << "0 0 " << d << " 1 " << (d - s % d) % d << ' ' << (s + d - 1) / d;
}



Measured memory_bytes: 256
#include <stdio.h>

// queue begin

#define QUEUE_SIZE 100000

typedef struct _point {
  int x, y;
} point;

point que[QUEUE_SIZE];
int head, tail;

void init() {
  head = tail = 0;
}

void push(point elm) {
  que[tail] = elm;
  tail = (tail+1) % QUEUE_SIZE;
}

point pop() {
  point elm = que[head];
  head = (head+1) % QUEUE_SIZE;
  return elm;
}

int empty() {
  return head == tail;
}

// queue end

#define MAXH 31
#define MAXW 31
#define INF (1<<28)

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

// G[y][x][d]: テ、ツスツ催ァツスツョ(x,y)テ」ツ?凝」ツつ嘉ヲツ鳴ケテ・ツ青租テ」ツ?ォテァツァツサテ・ツ仰陛」ツ?古・ツ渉ッティツδステ」ツ?凝」ツ?ゥテ」ツ??」ツ??
int G[MAXH][MAXW][4];
int cost[MAXH][MAXW];

int bfs(int sx, int sy, int gx, int gy) {
  int i, j;
  point p = {sx, sy};
  point np;

  if(sx == gx && sy == gy) return 0;

  for(i = 0; i < H; ++i) {
    for(j = 0; j < W; ++j) {
      cost[i][j] = INF;
    }
  }
  cost[sy][sx] = 0;
  init();
  push(p);
  while(!empty()) {
    p = pop();
    for(i = 0; i < 4; ++i) {
      if(G[p.y][p.x][i]) {
        np.x = p.x + dx[i];
        np.y = p.y + dy[i];
        if(cost[np.y][np.x] == INF) {
          push(np);
          cost[np.y][np.x] = cost[p.y][p.x] + 1;
          if(np.x == gx && np.y == gy) {
            return cost[np.y][np.x];
          }
        }
      }
    }
  }
  return INF;
}

int main() {
  int i, j, k, a, ans;
  while(scanf("%d %d", &W, &H) != EOF) {
    if(W == 0 && H == 0) break;
    for(i = 0; i < H; ++i) {
      for(j = 0; j < W; ++j) {
        for(k = 0; k < 4; ++k) {
          G[i][j][k] = 0;
        }
      }
    }
    for(i = 0; i < H*2-1; ++i) {
      if(i % 2 == 0) {
        for(j = 0; j < W-1; ++j) {
          scanf("%d", &a);
          if(a == 0) {
            G[i/2][j][0] = G[i/2][j+1][2] = 1;
          }
        }
      } else {
        for(j = 0; j < W; ++j) {
          scanf("%d", &a);
          if(a == 0) {
            G[i/2][j][1] = G[i/2+1][j][3] = 1;
          }
        }
      }
    }
    ans = bfs(0,0,W-1,H-1);
    if(ans == INF) ans = 0;
    else ++ans;
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main(){
    long long int N,D,x,y;
    int ans=0;
    cin >> N;
    cin >> D;
    rep(i,N){
      cin>>x>>y;
      long long int p;
      p=x*x+y*y;
      if(p<=D*D){
        ans++;
    }

      }


      cout<<ans<<endl;


}


Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int ans = 1;
  while(ans*2<=N) ans *= 2;
  cout<<ans<<endl;
}



Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
int main(){
    char str[10];
    scanf("%s", str);
    char *p;
    p = strtok(str, "/");

    int y, m, d;
    y = atoi(p);
    p = strtok(NULL, "/");
    m = atoi(p);
    p = strtok(NULL, "/");
    d = atoi(p);
    if (m < 5){
        printf("%s\n", "Heisei");
        }
    else{
        printf("%s\n", "TBD");
        }
    return 0;
}

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

int main(void){
    char a;
    
    cin >> a;
    
    if(a == 'a'){ a = 'b';}
    else if(a == 'b') {a = 'c';}
    else if(a == 'c') {a = 'd';}
    else if(a == 'd') {a = 'e';}
    else if(a == 'e') {a = 'f';}
    else if(a == 'f') {a = 'g';}
    else if(a == 'g') {a = 'h';}
    else if(a == 'h') {a = 'i';}
    else if(a == 'j') {a = 'k';}
    else if(a == 'm') {a = 'n';}
    else if(a == 'n') {a = 'o';}
    else if(a == 'o') {a = 'p';}
    else if(a == 'p') {a = 'q';}
    else if(a == 'q') {a = 'r';}
    else if(a == 'r') {a = 's';}
    else if(a == 's') {a = 't';}
    else if(a == 't') {a = 'u';}
    else if(a == 'u') {a = 'v';}
    else if(a == 'v') {a = 'w';}
    else if(a == 'w') {a = 'x';}
    else if(a == 'x') {a = 'y';}
    else if(a == 'y') {a = 'z';}
    //help me
    
    cout << a << endl;
    
    return 0;
}


Measured memory_bytes: 256
l = input().split()
l[0]=int(l[0])
l[1]=int(l[1])
MAX=int(1e+18)

if (l[0] % l[1])==0:
    print(-1)
    exit()

for i in range(1,l[1]):
    if (l[0]*i)>MAX:
        print(-1)
        exit()
    if (l[0]*i)%l[1]!=0:
        print(l[0]*i)
        exit()


Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
point = 0

for i in range(n):
  point += b[a[i]-1]
  if i <= n-2 and a[i+1] == a[i] + 1:
    point += c[a[i]-1]

print(point)

Measured memory_bytes: 3064
s = input()
t = input()

ans = 2000  # 制約以上の大きな値
for i in range(len(s) - len(t) + 1):
    diff = 0
    for j in range(len(t)):
        if (s[i + j] != t[j]):
            diff += 1
    ans = min(diff, ans)

print(ans)


Measured memory_bytes: 9108
/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!(n: usize, a: usize, b: usize);
    let interval = b - a - 1;
    if interval % 2 == 1 {
        println!("Alice");
    } else {
        println!("Borys");
    }
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {



        
        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                //if (n == 0) { break; }
                if (n == 0) { Console.WriteLine(0); continue; }
                if (n == 1) { Console.WriteLine(1); continue; }
                if (n == 2) { Console.WriteLine(2); continue; }
                if (n == 3) { Console.WriteLine(5); continue; }

                int node = 0; int edge = 0;
                if (n % 2 == 0) {
                    // e.g. n==4,
                    //
                    //    O  -  O
                    //  / ||  / ||
                    // O  OO O  OO   <- Tree Depth = n/2 -1
                    node = 2; edge = 6;
                    for (int i = 0; i < n / 2 - 1; i++) {
                        node += edge;
                        edge *= 3;
                    }
                }
                else {
                    //e.g. n ==5,
                    //
                    //      O
                    //    / || |
                    //   O  OO O
                    //  /||  
                    // O OO ...     <- Tree Depth = (n-1)/2
                    node = 1; edge = 4;
                    for (int i = 0; i < (n - 1) / 2; i++) {
                        node += edge;
                        edge *= 3;
                    }
                }
                
                Console.WriteLine(node);

    
            }
        }


    }

    
}

Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  string S;
  cin>>S;
  
  if(S=="ABC")
    cout<<"ARC"<<endl;
  else if(S=="ARC")
    cout<<"ABC"<<endl;
}


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

// 
int main() {
    int N;
    cin >> N;
    map<string, int> caseMap;
    caseMap["AC"] = 0;
    caseMap["WA"] = 0;
    caseMap["TLE"] = 0;
    caseMap["RE"] = 0;

    string caseS;
    for (int i = 0; i < N; i++) {
        cin >> caseS;
        caseMap[caseS]++;
    }

    cout << "AC x " << caseMap["AC"] << endl;
    cout << "WA x " << caseMap["WA"] << endl;
    cout << "TLE x " << caseMap["TLE"] << endl;
    cout << "RE x " << caseMap["RE"] << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << - 1 << endl;}
void unhap() {cout << ":(" << endl;}

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p.at(i);
  sort(p.begin(), p.end());
  int sum = p.at(n - 1) / 2;
  for (int i = 0; i < n - 1; i++) sum += p.at(i);
  cout << sum << endl;
}

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

namespace ConsoleApp17
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = Convert.ToInt32(input[0]);
            int b = Convert.ToInt32(input[1]);

            int c = b;
            if(a<=12&&a>=6)
            {
                c = b / 2;
            }
            else if(a>13)
            {
                c = b;
            }
            else if(a<=5)
            {
                c = 0;
            }

            Console.Write(c);
            Console.Read();
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  if ((a*b)%2) dump("Odd");
  else dump("Even");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int n,i,k,tmp,t=0;
   scanf("%d%d",&n,&k);
   int l[n];

   for(i=0;i<n;i++)
      scanf("%d",&l[i]);

   for(i=0;i<n-1;i+=0)
      if(l[i]<l[i+1]){tmp=l[i]; l[i]=l[i+1]; l[i+1]=tmp; i=0;}
      else i++;

   for(i=0;i<k;i++)
      t+=l[i];

   printf("%d\n",t);

   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); (i)--)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
using namespace std;
typedef long long lint;

int n, t[17][17], dp[17][1<<17];
const int MAX = 10000000;

int main(){
    while(true){
        cin >> n;
        if(!n) return 0; 
        rep(i, n)rep(j, n+1) cin >> t[i][j];
        rep(i, n+1)rep(j, 1<<n) dp[i][j] = MAX;
        dp[0][0] = 0;
        rep(i, n)rep(j, 1<<n){
            rep(k, n)if(!((j>>k)&1)){
                int nj = j | (1<<k);
                rep(l, n){
                    dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + t[k][0]);
                    if((j>>l)&1) dp[i+1][nj] = min(dp[i+1][nj], dp[i][j] + t[k][l+1]);
                }
            }
        }
        cout << dp[n][(1<<n)-1] << endl;
    }
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 20;

int n, res;
int judge[N];
int c[N];
struct Testimonie
{
    int t, id;
}testimonies[N][N];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> c[i];
        for(int j = 1; j <= c[i]; j++)
            cin >> testimonies[i][j].id >> testimonies[i][j].t;
    }

    for(int k = 0; k < (1 << n); k++)
    {
        int cnt = 0;
        bool flag = true;
        for(int i = 0; i < n; i++)
        {
            judge[i + 1] = (k >> i) & 1;
            cnt += judge[i + 1];
        }

        for(int i = 1; i <= n; i++)
            if(judge[i])
                for(int j = 1; j <= c[i]; j++)
                {
                    if(judge[testimonies[i][j].id] + testimonies[i][j].t == 1)
                    {
                        flag = false;
                        break;
                    }
                }

        if(flag) res = max(res, cnt);
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)((v).size())
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#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 M 100010



// abs(i-j)=a[i]+a[j]
// i-j=a[i]+a[j]
// i-a[i] = j+a[j]   
int main(){
    IOS;
    tihs;
    
    ll n;cin>>n;
    ll a[n];
    map<ll,ll>mp1,mp2;
    rep(i,0,n){
    	cin>>a[i];
    	mp1[i-a[i]]++;
    	mp2[i+a[i]]++;
    }
    ll ans=0;
    for(auto i:mp1){
    	ans+=(i.se*mp2[i.fi]);
    }
    cout<<ans;
   	
    
   	
    return 0;
}

Measured memory_bytes: 39544
#include <stdio.h>
#include <iostream>
#include <cmath>

using namespace std;

unsigned int findGreatCommonDivisor(unsigned int a,unsigned int b){
    unsigned int startNum;
    unsigned int divisor;
    if(a>b){
        startNum = a;
        divisor = b;
    }else{
        startNum = b;
        divisor = a;
    }
    
    if(startNum%divisor == 0){
        return divisor;
    }
    else{
        return findGreatCommonDivisor(startNum%divisor,divisor);
    }
    
    
    /*
    if(a>b){
        startNum = a;
    }else{
        startNum = b;
    }
    
    bool hasFound = false;
    if(a%startNum == 0&&b%startNum == 0){
        hasFound = true;
    }else{
        startNum = startNum/2 +1;
    }
    
    while(!hasFound){
        if(a%startNum == 0&&b%startNum == 0){
            hasFound = true;
        }else{
            startNum--;
        }
    }
    */
}

int main()
{
	unsigned int a;
    unsigned int b;
    cin>>a>>b;
    cout<<findGreatCommonDivisor(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
template<class C>constexpr int sz(const C&c){return int(c.size());}
using ll=long long;constexpr const char nl='\n',sp=' ';
 
int main() {
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // freopen("err.txt", "w", stderr);
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (auto &&a : A) cin >> a;
  for (auto &&b : B) cin >> b;
  int mx = INT_MIN;
  for (int i = 0; i < N; i++) mx = max(mx, int(upper_bound(B.begin(), B.end(), A[i]) - B.begin() - i));
  if (mx < 0) mx += N;
  rotate(B.begin(), B.begin() + mx, B.end());
  for (int i = 0; i < N; i++) if (A[i] == B[i]) {
    cout << "No" << nl;
    return 0;
  }
  cout << "Yes" << nl;
  for (int i = 0; i < N; i++) cout << B[i] << " \n"[i == N - 1];
  return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	for(vs ss(3);cin>>ss[0],ss[0][0]!='0';){
		cin>>ss[1]>>ss[2];
		vector<pii> res(3);
		rep(i,3){
			repi(j,1,ss[i].size())
				if(ss[i][j]=='A')
					res[i].first++;
				else
					res[i].second++;
			if(res[i].first>res[i].second)
				res[i].first++;
			else
				res[i].second++;
			
			cout<<res[i].first<<" "<<res[i].second<<endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,ct;
  char s[100];
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>s[i];
  }
  ct=0;
  for(int i=0;i<n-2;i++)
  {
    if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C') ct++;
  }
  cout<<ct<<endl;
  return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>L>>R>>H>>W;
	vector<long long int>by(3000000,1);
	for(int i=2;i<3000000;i++){
		by[i]=by[i-1]*i;
		by[i]%=MOD;
	}
	long long int ans=0;
	ans=by[H+W+2]*power(by[H+1],MOD-2,MOD)%MOD*power(by[W+1],MOD-2,MOD)%MOD;
	ans+=MOD-1;
	ans%=MOD;
	long long int add=0;
	add=by[H+R+1]*power(by[H+1],MOD-2,MOD)%MOD*power(by[R],MOD-2,MOD)%MOD;
	add+=MOD-1;
	add%=MOD;
	ans+=MOD-add;
	add=by[W+L+1]*power(by[W+1],MOD-2,MOD)%MOD*power(by[L],MOD-2,MOD)%MOD;
	add+=MOD-1;
	add%=MOD;
	ans+=MOD-add;
	add=by[L+R]*power(by[L],MOD-2,MOD)%MOD*power(by[R],MOD-2,MOD)%MOD;
	add+=MOD-1;
	add%=MOD;
	ans+=add;
	ans%=MOD;
	cout<<ans<<endl;
}


Measured memory_bytes: 23808