akhauriyash/Code-Regression huggingface dataset:
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*2*10**6
for i in a:
    if b[i]==0:
        b[i]=-1
        for j in range(2,10**6):
            if i*j>10**6:
                break
            b[i*j]+=1
        continue
    
    if b[i]==-1:
        b[i]=1
cnt = 0
for i in a:
    if b[i]==-1:
        cnt+=1
print(cnt)

Measured memory_bytes: 130572
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,p,ans=1;
    cin >> n >> p;
    if(n==1) cout << p << endl;
    else{
    for(long i=2;i*i<=p;i++){
        long c=0;
        while(p%i==0){
            c++;
            p /= i;
        }
        ans *= pow(i,c/n);
    }
    cout << ans << endl;
    }
}

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

void solve(long long N, std::vector<long long> a){
    map<ll, ll> mp;
    for(ll i = 0; i < N; ++i) mp[a[i]]++;
    ll ans = 0;
    for(auto p: mp){
        ll x = p.first;
        ll n = p.second;
        if(n < x) ans += n;
        else ans += n - x;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

bool evenNumber(int);

int main(){

	int n, m;
	int a, b;

	std::cin >> n >> m;

	std::vector<int> node(m);
	 
	for (auto&& cnt:node) {
		std::cin >> a >> b;

		node[a - 1] += 1;
		node[b - 1] += 1;
	}

	for (auto&& cnt : node) {
		if (!evenNumber(cnt)) {
			std::cout << "NO";
			return 0;
		}
	}
	std::cout << "YES";


}

bool evenNumber(int _input) {
	if (_input % 2 == 0) {
		return true;
	}
	return false;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000000000000000
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  vector<vector<ll>> dp(n,vector<ll>(5));
  dp[0][0]=dp[0][4]=a[0];
  dp[0][1]=dp[0][3]=(a[0]==0?2:a[0]%2==0?0:1);
  dp[0][2]=(a[0]%2==0?1:0);
  for(int i=1;i<n;i++){
    dp[i][0]=dp[i-1][0]+a[i];
    dp[i][1]=min(dp[i-1][0],dp[i-1][1])+(a[i]==0?2:a[i]%2==0?0:1);
    dp[i][2]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2]})+(a[i]%2==0?1:0);
    dp[i][3]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2],dp[i-1][3]})+(a[i]==0?2:a[i]%2==0?0:1);
    dp[i][4]=min({dp[i-1][0],dp[i-1][1],dp[i-1][2],dp[i-1][3],dp[i-1][4]})+a[i];
  }
  cout<<min({dp[n-1][0],dp[n-1][1],dp[n-1][2],dp[n-1][3],dp[n-1][4]});
}

Measured memory_bytes: 15104
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back

int mod = 1000000007;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};


int32_t main(){
	IO
	int n,x,y;
	cin>>n>>x>>y;
	for(int i=1;i<=n-1;i++){
	    g[i].push_back(i+1);
	    g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	
	//graph is completed
	int distance[n+1]={0};
	for(int i=1;i<=n;i++){
	    queue<int> q;
	    vector<int> door(n+1,INT_MAX);
	    door[i]=0;
	    q.push(i);
	    while(!q.empty()){
	        int u = q.front();
	        q.pop();
	        //for all neighbours
	        for(int j=0;j<g[u].size();j++){
	            int v = g[u][j];
	            if(door[u]+1<door[v]){
	                if(door[v]!=INT_MAX)
	                distance[door[v]] -= 1;
	                door[v] = door[u]+1;
	                distance[door[v]] += 1;
	                q.push(v);
	            }
	        }
	    }
	    //for(int i=1;i<=n-1;i++)cout<<distance[i]<<" ";
	    //cout<<"\n";
	   // exit(0);
	   // for(int i=1;i<=n;i++)cout<<door[i]<<" ";
	   // cout<<"\n";
	    
	}
	//exit(0);
	for(int i=1;i<=n-1;i++){
	    cout<<distance[i]/2<<"\n";
	}
	
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int INF = 1000000007;

int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  int B[N];
  B[0] = 0;
  int ans = 0;
  for(int i=1;i<N;i++){
    if(A[i-1] >= A[i]){
      B[i] = B[i-1] + 1;
    }
    else{
      B[i] = 0;
    }
    ans = max(ans, B[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n,len,x=0;
	int nA=0,nB=0,nAB=0;
	cin>>n;
	while(n--)
	{
		string arr;
		cin>>arr;
		len=arr.size();
		for(int i=0;i<len-1;i++)
		{
			if(arr[i]=='A'&&arr[i+1]=='B')
				nAB++;
		}
		if(arr[0]=='B')
			nB++;
		if(arr[len-1]=='A')
			nA++;
		if(arr[0]=='B'&&arr[len-1]!='A'||arr[0]!='B'&&arr[len-1]=='A')
			x=1;
	}
	if(x==0&&nA>0)
		nA--;
	cout<<nAB+min(nA,nB);
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    from collections import defaultdict

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    nd = defaultdict(int)
    for i in range(1, n+1):
        tmp = str(i)
        h, t  = int(tmp[0]), int(tmp[-1])
        nd[(h, t)] += 1
    
    ans = 0
    for i in range(1, 10):
        for j in range(1, 10):
            ans += nd[(i, j)]*nd[(j, i)]
    print(ans)



    
if __name__ == '__main__':
    main()

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

public class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long a = scanner.nextLong();
    long b = scanner.nextLong();
    long c = scanner.nextLong();
    
    if ((c - a - b) * (c - a - b) <= 4 * a * b || c-a-b < 0){
      System.out.println("No");
    } else{
      System.out.println("Yes");
    }

  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.1415926535
#define rep(i, k, n) for(ll i = k; i < n; i++)

vector<vector<char>> maze; //迷路を表す文字列
vvll d; //距離
ll INF = 10000000000;

ll r, c; 
ll dy[4] = {0, 1, 0, -1};
ll dx[4] = {1, 0, -1, 0};

ll bfs(){
  queue<pll> que;
  //全ての点をINFで初期化
  rep(i, 0, r){
    rep(j, 0, c){
      d[i][j] = INF;
    }
  }
  
  //スタート地点をキューに入れ、距離を0にする
  que.push(pll(0, 0));
  d[0][0] = 0;
  
  //キューが空になるまでループ
  while(que.size()){
    //キューの先頭を取り出す
    pll p = que.front();
    que.pop();
    
    //取り出してきたものがゴールなら探索終了
    if(p.first == r-1 && p.second == c-1){break;}
    
    //移動四方向ループ
    rep(i, 0, 4){
      //移動後の点(nx,ny)
      ll ny = p.first + dy[i];
      ll nx = p.second + dx[i];
      //移動可能か、すでに訪れているか判定
      if(ny >= 0 && ny < r && nx >= 0 && nx < c && d[ny][nx] == INF && maze[ny][nx] != '#'){
        //移動できるならキューに入れ、その点をpの距離＋１にする
        que.push(pll(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
      
  return d[r-1][c-1];
}
      

int main(){
  cin >> r >> c;
  
  maze = vector<vector<char>> (r,vector<char>(c));
  d = vvll (r,vll(c,INF));
  ll num_akichi = 0;
  
  rep(i, 0, r){
    rep(j, 0, c){
      cin >> maze[i][j];
      if(maze[i][j] == '.'){num_akichi ++;}
    }
  }
  
  ll dist = bfs();
 
  ll score;
  
  if(dist == INF){score = -1;}
  else{score = num_akichi - dist - 1;}
      
  cout << score << endl;    
      
}






Measured memory_bytes: 3656
X = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


while 1:
    if len(make_divisors(X)) == 2:
        break
    X += 1

print(X)

Measured memory_bytes: 38640
import fractions
if __name__ == "__main__":
    A, B, C, D = map(int, input().split())
    A -= C
    B -= D
    W = abs(A)
    H = abs(B)
    if W == 0 or H == 0:
        print(0)
        exit()
    res = W + H - 1
    g = fractions.gcd(W, H)
    print(res - g + 1)


Measured memory_bytes: 5048
def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

memo = {}

def run():
    n = input_int()

    memo = {}
    result = find_patterns(n, memo)

    result = result % (1000000000 + 7)

    print(result)


def find_patterns(num, memo: {}):

    if num < 3:
        return 0

    if num == 3:
        return 1

    if num in memo:
        return memo[num]

    sum_num = 1
    for i in range(3, num):
        sum_num += find_patterns(num - i, memo)

    memo[num] = sum_num
    return sum_num

run()



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

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

signed main() {
   fio;
   int n , d; cin >> n >> d;
   int res = 0;
   for(int i = 0; i < n; i++) {
      int x , y; cin >> x >> y;
      if(x * x + y * y <= d * d) {
         res++;
      }
   }
   
   cout << res << endl;
   
   return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF 1LL<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
const int mod = 1e9 + 7;

int main(){
    ll a,b,k; cin >> a >> b >> k;
    rep(i,k){
        if(i%2==0){
            b += a/2;
            a = a/2;
        }else{
            a += b/2;
            b = b/2;
        }
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

ll d;
vector<vl> s;
vl c(26);
vector<set<ll>> st(26, {-1});
ll score;

void add(ll i, ll k) {  // i日目(0-index)、テストk（0-index）
  st[k].insert(i);
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score += c[k] * (i - prev) * (next - i) + s[i][k];
}

void rm(ll i, ll k) {
  auto pi = st[k].lower_bound(i);
  pi--;
  ll prev, next;
  if(pi == st[k].begin())
    prev = -1;
  else
    prev = *pi;
  auto ni = st[k].upper_bound(i);
  if(ni == st[k].end())
    next = d;
  else
    next = *ni;
  score -= c[k] * (i - prev) * (next - i) + s[i][k];
  st[k].erase(i);
}

void eval(vl &t) {
  rep(i, d) {
    ll k = t[i];
    add(i, k);
  }
}

int main() {
  cin >> d;
  rep(i, 26) cin >> c[i];
  s.resize(d, vl(26));
  rep(i, d) rep(j, 26) cin >> s[i][j];

  score = -accumulate(all(c), 0LL) * d * (d + 1) / 2;

  // for B
  vl t(d), v(d);
  rep(i, d) {
    cin >> t[i];
    t[i]--;
  }
  eval(t);

  // for C
  ll m;
  cin >> m;
  rep(i, m) {
    ll qd, qt;
    cin >> qd >> qt;
    qd--;
    qt--;
    rm(qd, t[qd]);
    add(qd, qt);
    t[qd] = qt;
    cout << score << '\n';
  }
}

Measured memory_bytes: 3700
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func switch_num(num string) string {
	if num == "0" {
		return "1"
	} else if num == "1" {
		return "0"
	} else {
		return num
	}
}

func main() {
	var s, pre_s string
	var ans_0, ans_1 int
	fmt.Scan(&s)
	s_list := strings.Split(s, "")
	pre_s = "0"
	for _, num := range s_list {
		if num == pre_s {
			ans_0++
			pre_s = switch_num(num)
		} else {
			pre_s = num
		}
	}
	pre_s = "1"
	for _, num := range s_list {
		if num == pre_s {
			ans_1++
			pre_s = switch_num(num)
		} else {
			pre_s = num
		}
	}
	if ans_0 > ans_1 {
		fmt.Println(ans_1)
	} else {
		fmt.Println(ans_0)
	}
}

Measured memory_bytes: 2944
#if 1
#include <iostream>
#include <fstream>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <iomanip>
#include <assert.h>

#define in std::cin
#define out std::cout

int main()
{
	int32_t N, x;
	in >> N >> x;
	int32_t l, r;
	int64_t count = 0;
	in >> r;
	if (x < r) {
		count += (r - x);
		r = x;
	}
	for (int32_t i = 1; i < N; ++i)
	{
		l = r;
		in >> r;
		if (x < l + r) {
			auto eat = (l + r) - x;
			r -= eat;
			assert(0 <= r);
			count += eat;
		}
	}
	out << count << std::endl;
}
#endif


Measured memory_bytes: 888
#方針: 最頻値に揃える
n = gets.to_i
v = gets.split

odd = v.select.with_index{|v, i| i.odd?}
even = v.select.with_index{|v, i| i.even?}

odd2 = odd.group_by{|v| v}.sort_by{|key, value| value.size}.reverse
even2 = even.group_by{|v| v}.sort_by{|key, value| value.size}.reverse

if odd2[0]!=even2[0]
  #最頻値が異なるなら素直に出力
  p n/2-odd2[0][1].size + n/2-even2[0][1].size
else
  #最頻値が同じなら二番目に多いやつに切り替え
  ans1, ans2 = n/2, n/2
  ans1 = n/2-odd2[1][1].size + n/2-even2[0][1].size if odd2[1]
  ans2 = n/2-odd2[0][1].size + n/2-even2[1][1].size if even2[1]
  p [ans1,ans2].min
end

Measured memory_bytes: 27380
#include<iostream>
using namespace std;
int main() {
	int c[9], sum = 0;
	for (int i = 0; i < 9; i++) {
		cin >> c[i];
		sum += c[i];
	}
	if (sum % 3 != 0) {
		cout << "No" << endl;
		return 0;
	}
	sum = sum / 3;
	if (c[0] + c[4] + c[8] == sum && c[2] + c[3] + c[7] == sum && c[1] + c[5] + c[6] == sum && c[2] + c[4] + c[6] == sum && c[1] + c[3] + c[8] == sum && c[0] + c[5] + c[7] == sum) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        if(s.charAt(1) == 'B'){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
    }

    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr]))
                ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext())
                throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }

}


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

bool acgt(char ch)
{
  char atgc[]="ACGT";
  for(int j=0 ; j<4 ; ++j)
  {
      if(ch==atgc[j])
      {
        return true;
      }
  }
  return false;
}

int main()
{
	int n;
  	cin>>n;
  	int west,mountain;
  	cin>>west;
  	int ans=1;
  	for(int i=1 ; i<n ; ++i)
    {
    	cin>>mountain;
      	ans+=(mountain>=west);
      	west=max(west,mountain);
    }
  	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
//#define _CRT_NONSTDC_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <fstream>
#include <numeric>
#include <sstream>
#include <algorithm>
#include <string>
#include <cstring>
#include <iomanip>
#include <unordered_map>
#include <ctime>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
 
 
using namespace std;
typedef long long ll;
typedef long double ld;
                        
#define all(x)   (x).begin(), (x).end()           /*sorting STL */
#define fastio	 ios_base::sync_with_stdio(0);  cin.tie(nullptr);  cout.tie(nullptr)
 
#define TRIPmin(a, b, c) 	min(a, min(b, c))
#define TRIPmax(a, b, c)    max(a, max(b, c))
#define fillchar(a,x) 		memset(a, x, sizeof (a))
 
// #define MOD		(1000000000+7)
 
/***********************************************************************/

int main() {
	string s;
	cin >> s;
	ll ans = 0;
	vector<char> tmp;
	for(ll i = 0; i <= s.length()-1; i++) {
		if(s[i] == 'R') tmp.push_back('R');
		else {
			ans = max(ans, (ll)tmp.size());
			tmp.clear();
		}
	}
	ans = max(ans, (ll)tmp.size());
	cout << ans;
	return 0;
}

Measured memory_bytes: 3620
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define vv vector< vector< int > >
#define ll long long
#define ALL(a) (a).begin(), (a).end()
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;

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; }

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

int main(){
    int X;
    cin >> X;
    while(X < 10E5){
        if(isPrime(X)){
            cout << X << endl;
            return 0;
        }
        X++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n,k,cnt=0,ans=1;
int head[200005],depth[100005],a[100005];

struct node
{
	int u,v;
}tmp[100005];

struct edge
{
	int next;
	int to;
}e[200005];

inline void add_edge(int u,int v)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}

inline void dfs(int now,int fath)
{
	depth[now]=depth[fath]+1;
	for (int i=head[now];i;i=e[i].next)
	{
		if (e[i].to!=fath)  dfs(e[i].to,now);
	}
}

inline void dfs2(int now,int fath)
{
	if (depth[now]==2)  a[now]--;
	else if (depth[now]>=3)  a[now]-=2;
	
	int flag=0,last;
	for (int i=head[now];i;i=e[i].next)
	{
		if (e[i].to!=fath)
		{
			if (flag==0)
			{
				last=a[e[i].to];
				flag=1;
				continue;
			}
			a[e[i].to]=last-1;
			last=a[e[i].to];
		}
	}
	for (int i=head[now];i;i=e[i].next)
	{
		if (e[i].to!=fath)  dfs2(e[i].to,now);
	}
}

signed main()
{
	cin>>n>>k;
	for (int i=1;i<n;i++)  cin>>tmp[i].u>>tmp[i].v;
	for (int i=1;i<=n;i++)  a[i]=k;
	for (int i=n;i>=1;i--)
	{
		add_edge(tmp[i].u,tmp[i].v);
		add_edge(tmp[i].v,tmp[i].u);
	}
	dfs(1,0);
	dfs2(1,0);
	
	for (int i=1;i<=n;i++)
	{
		int gx=max(a[i],0ll);
		ans=(ans*gx)%mod;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back

typedef long long llo;
llo n,m;
vector<llo> adj[100001];
llo val[100001];
llo st=1;
llo co[3];
void dfs(llo no,llo ac=1){
	val[no]=ac;
	co[ac]+=1;
	for(auto j:adj[no]){
		if(val[j]==0){
			dfs(j,3-ac);
		}
		else{
			if(val[j]==val[no]){
				st=0;
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n>>m;

	for(llo i=0;i<m;i++){
		llo aa,bb;
		cin>>aa>>bb;
		aa--;
		bb--;
		adj[aa].pb(bb);
		adj[bb].pb(aa);
	}
	dfs(0);
	llo ans;
	if(st==0){
		ans=((n*(n-1)))/2-m;
	}
	else{
		ans=co[1]*co[2]-m;
	}
	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 11728
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n;
cin>>n;
ll arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
	ll ans=0;
ll m=0;
for(int i=0;i<n;i++){
   if(m>=arr[i]){
   	ans+=(abs(m-arr[i]));
   }
  m=max(m,arr[i]);
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 5216
use proconio::input;
use std::cmp;

fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    }

    let ans = cmp::min(a, k) - cmp::max(cmp::min(k - a - b, c), 0);
    println!("{}", ans);
}


Measured memory_bytes: 2140
#include "bits/stdc++.h"
using namespace std;

//template
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v,a,b) v.begin(a),v.end(b)
#define in cin>>
#define out cout<<
#define endl <<endl
#define INF 1000000

int main() 
{
	int N, W;
	in N >> W;
	vector<int> w(110);
	vector<int> v(110);
	rep(i, N)
	{
		in w.at(i) >> v.at(i);
	}
	vector<vector<ll>> ans(110, vector<ll>(100100 , 0));
	rep(i, N)
	{
		rep(j, W + 1)
		{
			if (j - w.at(i) >= 0)
			{
				ans.at(i + 1).at(j) = max(ans.at(i+1).at(j),ans.at(i).at(j-w.at(i))+v.at(i));
			}
			ans.at(i + 1).at(j) = max(ans.at(i + 1).at(j), ans.at(i).at(j));
		}
	}
	out ans.at(N).at(W) endl;
}


Measured memory_bytes: 87296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    vector<ll> vec;
    while (N!=0) {
        ll a;
        if (N%26 == 0) a = 26;
        else a = N%26;
        //cout << a << endl;
        vec.push_back(a);
        N -= a;
        N /= 26;
    }
    reverse(vec.begin(),vec.end());
    for (ll i = 0;i<vec.size();i++) {
        char a = 'a' + vec.at(i) - 1;
        cout << a;
    }


}


Measured memory_bytes: 3608
#include<cstdio>
#define HR 1000000007
using namespace std;
char s[1005];
int dp[1005][1005];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    dp[1][1]=1;
    for (int i=1;i<=n;i++){
        scanf("%s",s+1);
        for (int j=1;j<=m;j++)
        if ((i!=1||j!=1)&&(s[j]!='#')) dp[i][j]=(dp[i-1][j]+dp[i][j-1])%HR;
    }
    printf("%d\n",dp[n][m]);
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll l = 2;
    ll r = 2;
    for ( int i = n - 1; i >= 0; --i ) {
        ll tmp_l = ( l + a[i] - 1 ) / a[i];
        ll tmp_r = r / a[i];
        if ( tmp_l > tmp_r ) {
            puts("-1");
            return 0;
        }
        l = tmp_l * a[i];
        r = ( tmp_r + 1 ) * a[i] - 1;
    }
    cout << l << " " <<  r << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=998244353;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    vi dp(c+1);
    dp[a]=1;
    REP(i,b+1,d+1){
        vi ndp(c+1);
        ll sum=0;
        REP(j,1,c+1){
            sum*=i-1;
            sum+=dp[j];
            sum%=mod;
            ndp[j]=dp[j]*(j-1)+sum;
            ndp[j]%=mod;
        }
        dp=ndp;
    }
    ll ans=0;
    rep(i,c+1){
        ans+=dp[i]*modpow(d,c-i);
        ans%=mod;
    }
    out(ans);
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
    int n,m;
    long long keyn=1;
    long long keym=1;
    long long res;
    cin>>n>>m;
        for(int i=1; i<=n;i++){
            keyn=(keyn*i)%1000000007;
        }
        for(int i=1; i<=m; i++){
            keym=(keym*i)%1000000007;
        }
    if(n==m)res=(keyn*keym*2)%1000000007;
    else if(n-m==1||m-n==1)res=(keyn*keym)%1000000007;
    else res=0;
    cout<<res<<endl;
    return 0;
}


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

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    k-=sum;
    cout<<n+k/a[0];
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long int lli;
#define tc int t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define vi vector<int>
#define vll vector<lli>


int main() {
   fastio;
   lli x;
   cin>>x;
   lli ans=(x/500)*(1000)+((x%500)/5)*5;
   cout<<ans<<"\n";
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
#define INF INT_MAX
int data[2000001];
typedef pair<int,int> P;
void init();
void updata(int i,int x);
int find(P a,int node,int left,int right);

int main(){
  int m,a,b,c;
  scanf("%d %d",&n,&m);
  init();
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    if(a == 0) updata(b,c);
    else cout << find(P(b,c),0,0,n-1) << endl; 
  }
}

void init(){
  int l=1;
  while(l < n){
    l<<=1;
  }
  n = l;
  for(int i=0;i<=n*2;i++){
    data[i] = INF;
  }
  return;
}

void updata(int i,int x){
  i += n-1;
  data[i] = x;
  while(i > 0){
    i = (i-1)/2;
    data[i] = min(data[i*2+1],data[i*2+2]);
  }
  return;
}

int find(P a,int node,int left,int right){
  if(right < a.first || a.second < left) return INF;
  if(a.first <= left && right <= a.second) return data[node];
  int c1 =find(a,node*2+1,left,(right+left)/2);
  int c2 = find(a,node*2+2,(left+right)/2+1,right);
  return min(c1,c2);
}

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

struct SegmentTree {
private:
	std::vector<int> node;

public:
	explicit SegmentTree(int sz) :node(sz * 2, 0) {}

	int size() { return node.size() / 2; }

	void update(int x, int val) {
		x += size();
		node[x] += val;
		while (x /= 2) {
			node[x] = node[x * 2] + node[x * 2 + 1];
		}
	}

	int getsum(int p, int q) {
		int ret = 0;
		p += size();
		q += size();
		while (p < q) {
			if (p % 2 == 1) {
				ret += node[p];
				++p;
			}
			p /= 2;
			if (q % 2 == 1) {
				--q;
				ret += node[q];
			}
			q /= 2;
		}
		return ret;
	}
};

int main() {
	int n, m = 0, q = 0;
	std::cin >> n >> m >> q;
	SegmentTree st(n);
	std::vector<std::pair<int, std::pair<int, std::pair<int, int>>>> d;
	for (int i = 0; i < m; ++i) {
		int l, r;
		std::cin >> l >> r;
		--l;
		--r;
		d.emplace_back(r, std::make_pair(0, std::make_pair(l, i)));
	}
	for (int i = 0; i < q; ++i) {
		int l, r;
		std::cin >> l >> r;
		--l;
		--r;
		d.emplace_back(r, std::make_pair(1, std::make_pair(l, i)));
	}
	std::sort(d.begin(), d.end());
	std::vector<int> ans(q);
	for (auto i : d) {
		if (i.second.first == 0) {
			st.update(i.second.second.first, 1);
		}
		else {
			ans[i.second.second.second] = st.getsum(i.second.second.first, i.first + 1);
		}
	}
	for (auto i : ans) {
		std::cout << i << std::endl;
	}
	return 0;
}


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

int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0;i < a + 1;i++){
        for(int j = 0;j < b + 1;j++){
            for(int k = 0;k < c + 1;k++){
                if(500 * i + 100 * j + 50 * k == x)ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n;
int f[4][100005];
int a[100005],b[100005],c[100005];
main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
    f[1][1]=max(b[1],c[1]);
    f[2][1]=max(a[1],c[1]);
    f[3][1]=max(a[1],b[1]);
//    cout<<f[1][1]<<" "<<f[2][1]<<" "<<f[3][1];
    for(int i=2;i<=n;i++)
    {
        f[1][i]=max(f[2][i-1],f[3][i-1])+a[i];
        f[2][i]=max(f[1][i-1],f[3][i-1])+b[i];
        f[3][i]=max(f[1][i-1],f[2][i-1])+c[i];
    }
//    cout<<endl;
    cout<<max(f[1][n],max(f[2][n],f[3][n]));
}


Measured memory_bytes: 2560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
	    int n = Io.read();

	    if ((n & 1) == 0) Io.write(n);
	    else Io.write(n * 2);
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static int read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        br.close();
        return Integer.parseInt(line);
    }

    /**
     * 標準出力
     * @param answer
     */
    public static void write(int answer)
    {
        System.out.println(answer);
    }
}

Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
using namespace std;
int a[300001];
int n;
long long ans;
int main()
{
	cin>>n;
	for(int i=1;i<=3*n;i++)   cin>>a[i];
	sort(a+1,a+3*n+1);
	for(int i=3*n-1;i>=n+1;i-=2)
	{
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+5;
ll INF = 1e18;
const ll lg=22; 

ll fast(ll base , ll expo){
    ll res = 1;
    while(expo>=1){
        if(expo%2) res *= base;
        base *= base;
        expo /= 2;
    }
    return base;
}

void code_idhr_h(){
    ll N; cin>>N;
    string S;
    while(N>=1){
        ll md = N%26;
        if(md==0) md = 26;
        S.pb('a' + md - 1);
        // cout<<N<<endl;
        if(N==26) break;
        N -= md;
        N/=26;
    }
    reverse(S.begin(), S.end());
    cout<<S;
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  int vec[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>vec[i][j];
    }
  }
  int ans[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      ans[i][j]=0;
    }
  }
  int n;
  cin>>n;
  int p;
  for(int i=0;i<n;i++){
    cin>>p;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(p==vec[j][k]){
          ans[j][k]++;
        }
      }
    }
  }
  if(ans[0][0]+ans[0][1]+ans[0][2]==3||ans[1][0]+ans[1][1]+ans[1][2]==3||ans[2][0]+ans[2][1]+ans[2][2]==3){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(ans[0][0]+ans[1][0]+ans[2][0]==3||ans[0][1]+ans[1][1]+ans[2][1]==3||ans[0][2]+ans[1][2]+ans[2][2]==3){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(ans[0][0]+ans[1][1]+ans[2][2]==3||ans[0][2]+ans[1][1]+ans[2][0]==3){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

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

int n,m;

int main(){

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

    cin>>n>>m;
    cout<<(n-1)*n/2+(m-1)*m/2<<endl;

    return 0;
}

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

typedef long long ll;
const int INF = 1e8;
// const ll INF = 1LL << 60;
typedef pair<int, int> P;

string S;
int main() {
    cin >> S;
    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

stack<char> st;
int main(){
	int n;
	string s;
	
	cin >> n >> s;
	int l = 0,r = 0,len = s.size();
	for(int i = 0;i < len;i++){
		if(s[i]=='(') st.push(s[i]);
		else{
			if(!st.empty()&&st.top()=='('){
				st.pop();
			}
			else st.push(s[i]);
		}
	}
	while(!st.empty()){
		char t = st.top();
		if(t=='(') l++;
		else r++;
		st.pop();
	}
	while(r--) cout << "(";
	cout << s;
	while(l--) cout << ")";
}

Measured memory_bytes: 256
s = list(input())

ll = len(s)

ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

cnt = 0

for i in range(1, len(s)):
    if s[i].isupper():
        if i == 1 or i == ll - 1 or s[i] != 'C':
            ans = 'WA'
        cnt += 1

if cnt != 1:
    ans = 'WA'

print(ans)

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

long long all7(long long a)
{
    long long count = 0;
    while(a > 0)
    {
        if(a % 10 != 7)
        {
            count = 0;
            break;
        }
        a /= 10;
        count++;
    }

    return count;
}

int main(void)
{
    long long K;
    cin >> K;

    K *= 9;
    if(K % 7 == 0)
    {
        K /= 7;
    }

    long long amari = 10 % K;
    int i = 1;
    while (i <= 9e6)
    {
        if(amari == 1)
        {
            cout << i << endl;
            return 0;
        }
        amari *= 10;
        amari %= K;
        i++;
    }
    
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
int main(){
    char s[9];
    int c=0,i=0;
    scanf("%s",s);
  
    for(i=0;i<3;i++){
     if(s[i]=='1'){
       c+=1;
     }
    }
    printf("%d\n",c);
    return 0;
}

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

class BIT {
public:
	vector<int>dat; int size_ = 0;

	void init(int sz) {
		size_ = sz + 2;
		dat.resize(size_ + 2, 0);
	}
	void add(int pos, int x) {
		pos++;
		while (pos <= size_) {
			dat[pos] += x;
			pos += (pos&-pos);
		}
		return;
	}
	int sum(int pos) {
		int s = 0; pos++;
		while (pos >= 1) {
			s += dat[pos];
			pos -= (pos&-pos);
		}
		return s;
	}
};

long long hanten(vector<long long>E) {
	BIT Z; Z.init(E.size() + 2);
	long long Y = 0;
	for (int i = 0; i < E.size(); i++) {
		Y += (long long)(i - Z.sum(E[i]));
		Z.add(E[i], 1);
	}
	return Y;
}

long long N; long double A[100009], B[100009], C[100009];
int D1[100009];

long long solve_x(long double P1) {
	P1 -= 1e-13;
	vector<pair<long double, int>> vec1, vec2;
	for (int i = 0; i < N; i++) vec1.push_back(make_pair((C[i] - A[i] * -1000000000.0L) / B[i], i));
	for (int i = 0; i < N; i++) vec2.push_back(make_pair((C[i] - A[i] * P1) / B[i], i));

	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());

	for (int i = 0; i < vec1.size(); i++) D1[vec1[i].second] = i;
	
	vector<long long>G;
	for (int i = 0; i < vec2.size(); i++) G.push_back(D1[vec2[i].second]);
	
	return hanten(G);
}

long long solve_y(long double P1) {
	P1 -= 1e-13;
	vector<pair<long double, int>> vec1, vec2;
	for (int i = 0; i < N; i++) vec1.push_back(make_pair((C[i] - B[i] * -1000000000.0L) / A[i], i));
	for (int i = 0; i < N; i++) vec2.push_back(make_pair((C[i] - B[i] * P1) / A[i], i));

	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());

	for (int i = 0; i < vec1.size(); i++) D1[vec1[i].second] = i;

	vector<long long>G;
	for (int i = 0; i < vec2.size(); i++) G.push_back(D1[vec2[i].second]);

	return hanten(G);
}

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

	long long ZENBU = N * (N - 1) / 2;
	long long BORDER = (ZENBU + 1) / 2;

	long double L1 = -1e9, R1 = 1e9, M1;
	for (int i = 0; i < 80; i++) {
		M1 = (L1 + R1) / 2;
		long long G = solve_x(M1);
		if (G >= BORDER) R1 = M1;
		else L1 = M1;
	}

	long double L2 = -1e9, R2 = 1e9, M2;
	for (int i = 0; i < 80; i++) {
		M2 = (L2 + R2) / 2;
		long long G = solve_y(M2);
		if (G >= BORDER) R2 = M2;
		else L2 = M2;
	}

	printf("%.12Lf %.12Lf\n", M1, M2);
	return 0;
}

Measured memory_bytes: 9864
# https://atcoder.jp/contests/abc052/tasks/abc052_b

N = int(input())
S = input()

max_count = 0
curr_count = 0

for s in S:
    if s == 'I':
        curr_count += 1

    elif s == 'D':
        curr_count -= 1

    if curr_count > max_count:
        max_count = curr_count

print(max_count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    int a[n+1];
    rep(i,n){
        cin >> s[i] >> a[i];
    }
  	a[n]=0;
    rep(i,n){
            a[n-i-1]+=a[n-i];
    }
  	rep(i,n+1)debug(a[i]);
    string t;
    cin >> t;
    rep(i,n){
        if(s[i]==t){
            cout << a[i+1];
            return 0;
        }
    }


    
}

/*
*/



Measured memory_bytes: 256
#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 <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
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> struct edge { int from, to; T cost;};
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; }


int digit(int x){
  int res = 0;
  while (x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main() {
  int n; cin >>n;
  int res = 909999990;
  for (int a=1; a<n; a++){
    int b = n - a;
    chmin(res, digit(a) + digit(b));
  }
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	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;
	}
}

int main() {

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

	double ans = 0;
	double b = 0;
	rep(i, n) {
		b += 1.0 / (double)a[i];
	}

	cout << fixed << setprecision(10) << 1.0 / b << endl;

	return 0;
}

Measured memory_bytes: 256