akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
  int N, M;
  cin >> N >> M;
  const int cost[9] = {2,5,5,4,5,6,3,7,6};
  vector<int> A(M);
  rep(i, M) cin >> A[i];
  sort(A.begin(), A.end());

  int dp[N+1]; // dp[i] ... i本のマッチをちょうど使って作れる最大の桁数。
  dp[0] = 0;

  for(int i=1; i<N+1; i++) {
    int tmp_dp = -1000000000;

    rep(j, M) {
      int pre = i - cost[A[j]-1];
      if(pre<0) continue;
      else tmp_dp = max(dp[pre]+1, tmp_dp);
    }

    dp[i] = tmp_dp;
  }

  //cout << dp[N] << endl;

  int n = N;
  for(int i=dp[N]; i>0; i--) {
    // 第n桁目
    for(int j=M-1; j>=0; j--) {
      if(n-cost[A[j]-1]<0) continue; 
      
      if(dp[n-cost[A[j]-1]] == dp[n]-1) {
        cout << A[j];
        n -= cost[A[j]-1];
        break;
      }
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#140c
N = int(input())
list_A = []
list_B = list(map(int, input().split()))

#長さ N の値の分からない整数列 Aがあります。
#長さ N−1の整数列 Bが与えられます。このとき、
#   Bi≥max(Ai,Ai+1)
#が成立することが分かっています。
#Aの要素の総和として考えられる値の最大値を求めてください。

#N 6
#A 200 200 10 10  5  5
#B 200 300 10 10  5

temp_A = list_B[0]
ans = temp_A

for i in range(1,N-1):
    #print(i,":",temp_A,",",list_B[i])
    if temp_A > list_B[i]:
        temp_A = list_B[i]
        ans += temp_A
    else: #temp_A <= list_B[i]:
        ans += temp_A
        temp_A = list_B[i]

ans += list_B[-1]
        
print(ans)

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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int h, n, m = 0, a;
  cin >> h >> n;
  for (int i = 0; i < n; ++i){
	cin >> a;
       m += a;	
  }
  (m >= h) ? cout << "Yes\n" : cout << "No\n";
return 0;
}


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

ll power(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}

void solve() {
	ll n; cin >> n;
	cout << ((power(10, n) - power(9, n) * 2 % mod + mod) % mod + power(8, n) ) % mod;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	// int t; cin >> t;
	// while (t--)
	solve();

}



Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    long long sum = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        sum += h[i];
    }
    sort(h.rbegin(), h.rend());
    for(int i = 0; i < min(n,k); i++){
        sum -= h[i];
    }
    cout << sum << endl;
    return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, m, i, j;
	cin >> n >> m;
	vector<pii> a(m);
	for (i = 0; i < m; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a.begin(), a.end());
	vi v(n-1);
	for (i = 0; i < n-1; i++) {
		v[i] = i + 2;
	}
	int ans = 0;
	do {
		int now = 1;
		bool flag1 = true;
		for (i = 0; i < n - 1; i++) {
			bool flag = false;
			int next = v[i];
			for (j = 0; j < m; j++) {
				if (a[j].first == min(now, next) && a[j].second == max(now, next)) {
					flag = true;
				}
			}
			if (flag) {
				now = next;
			}
			else {
				flag1 = false;
			}
		}
		if (flag1) {
			ans++;
		}
	} while (next_permutation(v.begin(), v.end()));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const ll MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string L;
  cin>>L;
  ll N=L.length();
  ll ans=0ll;
  vector<vector<ll> > dp(2,vector<ll>(N+1,0ll));
  dp[0][0]=1ll;
  dp[1][0]=0ll;

  for(int i=0;i<N;i++){
    if(L[i]=='1'){
      dp[0][i+1] = dp[0][i]*2%MOD;
      dp[1][i+1] = dp[0][i]+dp[1][i]*3%MOD;
    }else{
      dp[0][i+1] = dp[0][i]%MOD;
      dp[1][i+1] = dp[1][i]*3%MOD;
    }
  }

  cout<<(dp[0][N]+dp[1][N])%MOD<<endl;
}


Measured memory_bytes: 2768
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()

    if N == 0:
        print(0)
    else:
        ans = []
        while abs(N) > 0:
            r = N % 2
            ans.append(r)
            if r == 1:
                N -= 1
            N //= -2

        print(''.join([str(i) for i in reversed(ans)]))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10120
#include <iostream>

using namespace std;

int main() {
  int A, B, C, tmp;
  cin >> A;
  cin >> B;
  cin >> C;

  tmp = A;
  A = B;
  B = tmp;

  tmp = A;
  A = C;
  C = tmp;

  cout << A << " " << B << " " << C;

  return 0;
}



Measured memory_bytes: 3576
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

class UnionFind():
    def __init__(self, n):
        self.n = n
        # parents[i]: 要素iの親要素の番号
        # 要素iが根の場合、parents[i] = -(そのグループの要素数)
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    # 要素xが属するグループの要素数を返す
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # 要素xが属するグループに属する要素をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    # 全ての根の要素をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    # グループの数を返す
    def group_count(self):
        return len(self.roots())
    # 辞書{根の要素: [そのグループに含まれる要素のリスト], ...}を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    # print()での表示用
    # all_group_members()をprintする
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
	N, M, K = MAP()
	friends = defaultdict(list)
	tree = UnionFind(N)
	for _ in range(M):
		A, B = MAP()
		tree.union(A-1, B-1)
		friends[A-1].append(B-1)
		friends[B-1].append(A-1)

	blocks = defaultdict(list)
	for _ in range(K):
		C, D = MAP()
		blocks[C-1].append(D-1)
		blocks[D-1].append(C-1)

	for i in range(N):
		minus = 0
		for b in blocks[i]:
			if tree.same(i, b):
				minus += 1
		print(tree.size(i)-len(friends[i])-1-minus, end=" ")
	print()

if __name__ == '__main__':
	main()


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

using ll =long long;

ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}

int main()
{
ll N;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec[i];
  }
  ll sum=0;
  sort(vec.begin(),vec.end());
  for(ll i=0;i<N-1;i++){
    sum+=vec[i];
  }
  sum+=vec[N-1]/2;
  
  cout<<sum<<endl;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
pros = sorted([list(map(int, input().split())) for _ in range(m)])
index = 0
covered = 0
right = 0
ans = 0
while True:
  a, b = pros[index]
  if a > covered + 1:
    if covered == right:
      print("Impossible")
      break
    covered = right
    ans += 1
    continue
  else:
    right = max(right, b)
    index += 1

  if covered == n:
    print(ans)
    break

  if index == m:
    covered = right
    ans += 1
    print(ans if covered == n else "Impossible")
    break



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

ans =0
n1 =0
m1 = 0

if N == 1:
    n1 = 1
else:
    n1 = N -2

if M == 1:
    m1 = 1
else:
    m1 = M -2

ans = n1*m1


print(ans)



Measured memory_bytes: 2940
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main() {
	int N;
	cin >> N;
	char a;
	vector<char>s;
	for (int i = 0;i < N;i++) {
		cin >> a;
		s.push_back(a);
	}
	for (int i = 0;i < N;i++) {
		if (s[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
	return 0;
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(),a.end())

typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//cout<<"input"<<endl;freopen("input.txt","r",stdin);
	//cout<<"output"<<endl;freopen("output.txt","w",stdout);
	int n,x;
	cin>>n;
	vector <int> dt;
	for(int i=1;i<=n;i++){
		cin>>x;
		dt.push_back(x);
	}
	int sum = 0;
	sort(dt.begin(),dt.end());
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(dt[i]==dt[j])	continue;
				if(dt[j]==dt[k])	continue;
				if(dt[k]==dt[i])	continue;
				if(dt[i]+dt[j] >dt[k]){
					sum+=1;
				}
			}
		}
	}
	cout<<sum<<endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ll t1 = h1*60 + m1;
    ll t2 = h2*60 + m2;
    cout << t2 - t1 - k << endl;

    return 0;
}

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

int main(void){
    int N;
    cin >> N;
    int W[N];
    for(int i = 0; i < N; i++) cin >> W[i];
    int min =101;
    int temp;
    int s1 = 0;
    int s2 = 0;
    for(int i = 1; i < N ; i++) {
        for(int k = 0; k < i; k++) s1 += W[k];
        for(int k = i; k < N; k++) s2 += W[k];
        if(s1 >= s2) temp = s1 - s2 ;
        if(s2 > s1) temp = s2 - s1 ;
        
        if(min > temp) min = temp;
        s1= 0;
        s2= 0;
    }
    cout << min;
}


Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define INF (int)1e9 + (int)1e8
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

double pi = 3.14159265358979323846264338327;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main() {
    cpp();
    ll n, m;
    cin>>n>>m;
    ll si, sj;
    cin>>si>>sj;
    --si, --sj;
    ll ei, ej;
    cin>>ei>>ej;
    --ei, --ej;
    vector<vector<ll> > v(n, vector<ll>(m));
    for(ll i=0; i<n; i++){
        for(ll j=0; j<m; j++){
            char c;
            cin>>c;
            if(c=='#'){
                v[i][j]=0;
            }
            else{
                v[i][j]=1;
            }
        }
    }
    if(v[si][sj]==0){
        cout<<-1<<endl;
        return 0;
    }
    priority_queue<vector<ll>, vector<vector<ll> >, greater<vector<ll> > > pq;
    pq.push({0, si, sj});
    vector<vector<ll> > vis(n, vector<ll>(m));
    vector<vector<ll> > dis(n, vector<ll>(m, INT_MAX));
    dis[si][sj]=0;
    vector<ll> dx({1, 0, -1, 0});
    vector<ll> dy({0, 1, 0, -1});
    while(!pq.empty()){
        auto p = pq.top();
        pq.pop();
        if(vis[p[1]][p[2]]) continue;
        vis[p[1]][p[2]]=1;
        for(ll k=0; k<4; k++){
            ll newX = p[1]+dx[k];
            ll newY = p[2]+dy[k];
            if(newX<0 || newY<0 || newX>=n || newY>=m) continue;
            if(v[newX][newY]==0) continue;
            if(dis[newX][newY]>dis[p[1]][p[2]]+0){
                dis[newX][newY]=dis[p[1]][p[2]];
                pq.push({dis[newX][newY], newX, newY});
            }
        }
        for(ll i=p[1]-2; i<=p[1]+2; i++){
            for(ll j=p[2]-2; j<=p[2]+2; j++){
                ll newX = i;
                ll newY = j;
                if(newX<0 || newY<0 || newX>=n || newY>=m) continue;
                if(v[newX][newY]==0) continue;
                if(dis[newX][newY]>dis[p[1]][p[2]]+1){
                    dis[newX][newY]=dis[p[1]][p[2]]+1;
                    pq.push({dis[newX][newY], newX, newY});
                }
            }
        }
    }
    cout<<(dis[ei][ej]!=INT_MAX?dis[ei][ej]:-1)<<endl;
    return 0;
}




Measured memory_bytes: 27440
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

signed main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] += 32;
	cout << s << endl;

	return 0;
}


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

using vi = vector<int>;
const int INF = 999999999;

int N, K;
vi a(100010), b(100010), c(100010);

// dp_a[i] = i日目にaを選ぶとした時の幸福度の最大値
vi dp_a(100010), dp_b(100010), dp_c(100010); 

int main(){
  cin >> N;
  for(int i=0; i<N; i++) cin >> a[i] >> b[i] >>  c[i];

  dp_a[0] = a[0]; dp_b[0] = b[0]; dp_c[0] = c[0];
  for(int i=1; i<N; i++){
    dp_a[i] = max(dp_b[i-1], dp_c[i-1])+a[i];
    dp_b[i] = max(dp_a[i-1], dp_c[i-1])+b[i];
    dp_c[i] = max(dp_a[i-1], dp_b[i-1])+c[i];
  }

  cout << max(dp_a[N-1], max(dp_b[N-1], dp_c[N-1])) << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;

  REP(i, s.length()) {
    if(s[i] == '?') cout << 'D';
    else cout << s[i];
  }

  cout << endl;
}


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

namespace abc153_c
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var K = CIn.ReadInt();
      var H = CIn.ReadIntArray(N);

      Array.Sort(H, (a, b) => b - a);

      var ans = 0L;

      for (var i = K; i < N; i++)
      {
        ans += H[i];
      }

      Console.WriteLine(ans);
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];
      for (var i = 0L; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(long h, long w)
    {
      var array = new char[h, w];
      for (var i = 0L; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0L; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    bool ans=true;
    if(N%2!=0){
        cout << "No" << endl;
        return 0;
    }
    for(int i=0;i<N/2;i++){
        if(s[i]!=s[N/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    string s;
    cin >> s;
    int ans =0;
    
    for(int i = 0; i < 4; i++)
    {
        if(s[i]=='2') ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// D.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

int main()
{
    int n;
    long long ans = 0;
    queue<int> q;

    cin >> n;

    vector<int> v(n);

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

    sort(v.begin(), v.end(), std::greater<int>());
    
    q.push(v[0]);
    int i = 1;
    while (i < n) {
        q.push(v[i]);
        q.push(v[i]);

        ans += q.front();
        q.pop();


        i++;
    }

    cout << ans << endl;


}


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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            double r = NextDouble();
            double pi = Math.PI;

            double menseki = r * r * pi;
            double enshuu = 2 * r * pi;

            Println(menseki.ToString("F5") + " " + enshuu.ToString("F5"));

        }

        public static void Println (Object o) {
            Console.WriteLine(o);
        }

        public static string NextString() {
            return Console.ReadLine();
        }

        public static int NextInt () {
            return int.Parse(Console.ReadLine());
        }

        public static int[] NextInts () {
            string[] a = Console.ReadLine().Split();
            int[] b = new int[a.Length];
            for (int i = 0; i < a.Length; i++) {
                b[i] = int.Parse(a[i]);
            }
            return b;
        }

        public static double NextDouble () {
            return double.Parse(Console.ReadLine());
        }

    }
}



Measured memory_bytes: 13868
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int par[100001];
vi adj[100001];
int dp[100001];

void dfs(int u)
{
	vi vec;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int v = adj[u][i];
		dfs(v);
		vec.pb(dp[v]);
	}
	sort(vec.begin(),vec.end());
	dp[u] = 0;
	for(int i = 0; i < vec.size(); i++)
	{
		int t = vec[i];
		if(dp[u]<t+1) dp[u]=t+1;
		else
		{
			dp[u]++;
		}
	}
	//cerr<<u<<' '<<dp[u]<<'\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i = 1; i < n; i++) 
	{
		cin>>par[i];
		par[i]--;
		adj[par[i]].pb(i);
	}
	dfs(0);
	cout<<dp[0]<<'\n';
}


Measured memory_bytes: 14336
n=int(input())
a,b=map(int,input().split())
p=list(map(int, input().split()))
p1 = [i for i in p if i <= a]
p2 = [i for i in p if i >= a+1 and i <= b]
p3 = [i for i in p if i >= b+1]
print(min(len(p1),len(p2),len(p3)))

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

int main(int argc, char* argv[]) {
	int a, b, c;
	int count = 0;
	cin >> a >> b >> c;

	for(int i = a; i <= b; i++){
		if(c % i == 0) count += 1;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n - 1];
        for(int i = 0; i < n; i++) {
        	a[i] = sc.nextInt() - 1;
        }
        for(int i = 0; i < n; i++) {
        	b[i] = sc.nextInt();
        }
        for(int i = 0; i < n - 1; i++) {
        	c[i] = sc.nextInt();
        }
        int sum = 0;
        for(int i =0; i < n; i++) {
        	sum += b[a[i]];
        	if (i != 0 && a[i] - a[i - 1] == 1) {
        		sum += c[a[i - 1]];
        		//System.out.println(sum);
        	}
        }
        System.out.println(sum);
	}

}


Measured memory_bytes: 21844
import numpy as np

q = int(input())
LR = np.array([input().split() for _ in range(q)], np.int64)
L, R = zip(*LR)

is_prime = np.zeros(max(R) + 1, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
M = int(max(R) ** .5) + 1
for p in range(3, M, 2):
    if is_prime[p]:
        is_prime[p * p::p + p] = 0

A = np.zeros(max(R) + 1, np.bool)
for i in range(max(R) + 1):
    j = (i + 1) // 2
    if is_prime[i] and is_prime[j]:
        A[i] = 1
S = np.zeros(len(A) + 1, np.int32)
S[1:] = np.cumsum(A)
for i in range(q):
    print(S[R[i] + 1] - S[L[i]])


Measured memory_bytes: 47420
def MI():return map(int,input().split())

n,m=MI()
sc=[]
for _ in range(m):
  s,c=MI()
  sc+=(s-1,c),
  
for i in range(0,999):
  S=str(i)
  if len(S)==n:
    if all([S[s]==str(c) for s,c in sc]):
      print(i)
      exit()
print(-1)

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

int main(){

    // 1. 入力情報取得.
    LL A, B;
    scanf("%lld %lld", &A, &B);
    
    // 2. K を 計算.
    LL K = (A + B) / 2;
    
    // 3. 出力 ～ 後処理.
    if(abs(A - K) == abs(B - K)) printf("%lld\n", K);
    else                         printf("%s\n", "IMPOSSIBLE");
    
    return 0;

}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; cin >> N >> K;
    if (K == 1) {
        cout << 0 << '\n';
    }
    else cout << (N-K) << '\n';
}



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

using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  bool flg = false;
  if( abs(a-c) <= d) flg = true;
  if( abs(a-b) <= d && abs(b-c) <= d) flg = true;
  
  cout << (flg ? "Yes" : "No") << endl;
}

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

using namespace std;

int main()
{
  unsigned n, s;
  
  while(cin >> n >> s, (n != 0 || s != 0)) {
    vector<unsigned> no(9);
    unsigned cnt = 0, sum = 0, i, k, max = 0, min = 0;
    for(i = 0; i < n ; i++){
      no[i] = i;
      min += i;
      max += 9 - i;
    }
    if(max < s || min > s) { cout << 0 << endl; continue; }
    cnt = 0;
    while(1) {
      //for(i = 0; i < n; i++) cout << i << no[i] << "  ";
      //cout << endl;
      for(k = sum = 0; k < n; k++) {
	sum += no[k];
      }
      if (sum == s) cnt++;
      //cout << sum << endl;
      if (sum >= s) no[n - 1] = 9;
      no[n - 1]++;
    
	for(k = n - 1; k > 0; k--) {
	  if(no[k] > 9 -  n  +  k + 1) {
	    no[k - 1]++;
	    for(i = k; i < n; i++) {
	      no[i] = no[i - 1] + 1;
	    } 
	  }
	}
	if(no[0] > 9 - n + 1) break;	    
    }
    cout << cnt << endl;
  }
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N;
    cin >> N;

    double tot = 0.;

    for (int i = 0; i < N; i++) {
        double amt;
        string cur;
        cin >> amt >> cur;

        if (cur == "JPY") tot += amt;
        else tot += 380000.0 * amt;
    }

    printf("%.15f\n", tot);

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,j,n,a[100],minj,cmp,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        minj=i;
        for(j=i;j<n;j++){
            if(a[j]<a[minj]){
                minj=j;
            }
        }
            if(i != minj){
                cmp = a[i]; 
                a[i] = a[minj];
                a[minj] = cmp;
                cnt++;
            
        }
    }
    for(i=0;i<n-1;i++)printf("%d ",a[i]);
    printf("%d\n",a[n-1]);
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int a=nextInt();
		int b=nextInt();

		long ans =(a+b)%24;
		System.out.println(ans);

	}

	public static boolean isPalindromicStr(String s) {
		int h = 0;
		int t = s.length() - 1;
		while (h <= t) {
			if (s.charAt(h) != s.charAt(t)) {
				break;
			}
			h++;
			t--;
		}
		if (h > t) {
			return true;
		}
		return false;
	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a > b) swap(a, b);
  if (a <= c && c <= b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

# random variable is all you need


def score(D, C, S, T):
    last = [-1] * 26
    # scores = [0]
    score = 0
    for d in range(D):
        # scores.append(scores[-1] + S[d][T[d]])
        score += S[d][T[d]]
        last[T[d]] = d
        for i in range(26):
            # scores[-1] -= C[i] * (d - last[i])
            score -= C[i] * (d - last[i])
    return score


from random import choices, seed

D = a_int()
C = ints()
S = read_tuple(D)

candi = list(range(26))

bestscore = -INF
for i in range(3 * 10000):
    seed(i)
    T = choices(candi, k=D)
    tmpscore = score(D, C, S, T)
    if tmpscore > bestscore:
        bestscore = tmpscore
        ansT = T
# print(score(D, C, S, ansT))
# print(bestscore)

print(*mina(*ansT, sub=-1), sep='\n')


Measured memory_bytes: 79672
#include <algorithm>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod 1000000007
#define int long long
#define double long double
#define INF LLONG_MAX/1000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
P a[200010];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	int sum = 0;
	rep(i, n) {
		sum += a[i].second;
		if (a[i].first < sum) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 7;

bool ok(int a[3])
{
	for (int i=0; i<3; i++)
		if (a[i] % 2 != 0)
			return false;
	return true;
}

int main()
{
	ios::sync_with_stdio(false);

	int a, b, c;
	cin >> a >> b >> c;
	int A[3] = {a, b, c};
	sort(A, A+3);
	int ans = 0;
	while (ok(A))
	{
		int a[3];
		a[0] = (A[1] + A[2]) / 2;
		a[1] = (A[0] + A[2]) / 2;
		a[2] = (A[0] + A[1]) / 2;
		sort(a, a+3);
		bool ok = false;
		for (int i=0; i<3; i++)
			if (a[i] != A[i])
				ok = true;
		if (!ok)
		{
			cout << "-1\n";
			return 0;
		}
		for (int i=0; i<3; i++)
			A[i] = a[i];
		ans++;
	}
	cout << ans << "\n";
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  vector<int> ans(S.size());

  int start = 0;
  char startStr = 'R';
  bool last = false;

  while(!last) {
    for(int i = start;i<S.size();i++) {
    if(startStr == 'R') {
      if(S[i] == 'R') {
        continue;
      } else {
        int diff = i - start;
        if(diff % 2 == 0) {
          ans[i] += diff / 2;
          ans[i-1] += diff / 2;
        } else {
          ans[i] += diff / 2;
          ans[i-1] += diff / 2 + 1;
        }

        start = i;
        startStr = 'L';
        break;
      }
    } else {
      if(i == S.size() - 1) {
        int diff = S.size() - start;

        if(diff % 2 == 0) {
          ans[start] += diff / 2;
          ans[start-1] += diff / 2;
        } else {
          ans[start] += diff / 2 + 1;
          ans[start-1] += diff / 2;
        }

        last = true;

        break;
      }
      if(S[i] == 'L') {
        continue;
      } else {
        int diff = i - start;
        if(diff % 2 == 0) {
          ans[start] += diff / 2;
          ans[start-1] += diff / 2;
        } else {
          ans[start] += diff / 2 + 1;
          ans[start-1] += diff / 2;
        }

        start = i;
        startStr = 'R';
        break;
      }
    }
  }
  }

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

  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
    string s;

    cin >> s;
    int ans = INF;
    for(int i = 0; i < s.size(); i++){
        int k = 0, t = i;
        for(int j = i + 1; j < s.size(); j++){
            if(s[i] == s[j]){
                t = max(t, k);
                k = 0;
            }
            else{
                k++;
            }
        }
        ans = min(ans, max(t, k));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
using i64 = int64_t;
using namespace std;

int64_t Combination(int n, int m) {
    if (n < m || m < 0 || n < 0) return 0;
    i64 retval = 1;
    for(int i = 1; i <= n - m; i++) {
        retval *= (i + m);
        retval /= i;
    }
    return retval;
}

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<i64> v(N);
    bool flag = false;
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    double ans = 0;
    double m = 1e15;
    for(int i = 0; i < A; i++) {
        ans += v[i];
        m = min(m, double(v[i]));
        if(i > 0 && v[i] != v[i - 1]) flag = true;
    }
    cout << std::fixed << std::setprecision(10) << (ans / A) << endl;
    int x = 0, y = 0;
    for(int i = 0; i < N; i++) {
        if(v[i] == m) {
            y++;
            if(i < A) x++;
        }
    }
    i64 ans2 = 0;
    if(flag) {
        ans2 = Combination(y, x);
    } else {
        for (int i = x; i <= x + (B - A); i++) {
            ans2 += Combination(y, i);
        }
    }
    cout << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

N,M = [int(x) for x in input().split()]

l = [[int(x) for x in input().split()] for _ in range(M)]



def do(l):

    count = 1

    l.sort()
    right = l[0][1]


    for i in range(len(l)):
        if l[i][0] >= right:
            right = l[i][1]
            count+=1
            continue
        if l[i][1] < right:
            right = l[i][1]
    return count

testl = [[x,x+1] for x in range(1)]

result = do(l)
print(result)

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

ull gcd( ull a, ull b) {
   if( a%b == 0 ){
     return( b );
   }else{
     return( gcd(b, a%b) );
   }
}

ull lcm( ull a, ull b ){
 return a*b / gcd(a, b);
}

int main(){
  ull k;
  cin >> k;
  ull ans = 0;
  for(ull i=1;i<=k;i++){
    for(ull j=1;j<=k;j++){
      for(ull l=1;l<=k;l++){
        ans += gcd(i,gcd(j,l));
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3672
//config = {stdin: 'tmp', newline: '\r\n'}; // win
config = {stdin: '/dev/stdin', newline: '\n'}; // linux

line = require('fs').readFileSync(config.stdin, 'ascii')
	.trim()
	.split(config.newline)
	;
line.shift();
line = line.map(function (line) {
	var ary = line.split(' ').map(Number);
	ary.sort(function (a, b) { return b - a; });
	if (sqr(ary[0]) === sqr(ary[1]) + sqr(ary[2])) return 'YES';
	else return 'NO';
});

console.log(line.join('\n'));

function sqr(x) { return x * x; }

Measured memory_bytes: 17624
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}


#pragma endregion


// 055 B - Training Camp
#define _dev 1000000007
int main(void) {
	int n;
	ll ans = 1;

	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		ans *= i;
		if (_dev > ans) continue;
		ans %= _dev;
	}
	printf("%lld\n",ans);
	return 0;
}






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

const int N = 200 * 1000 + 5;

int a[N];
int b[N];
int dp[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		b[a[i]] = i;
	}
	dp[1] = 1;
	int ans = 1;
	for (int i = 2; i <= n; i++) {
		if (b[i] > b[i - 1]) {
			dp[i] = dp[i - 1] + 1;
		}
		else {
			dp[i] = 1;
		}
		ans = max(ans, dp[i]);
	}
	cout << n - ans << endl;
	return 0;
}


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

int main(){
    int r,c;
    cin>>r>>c;
    vector<vector<int> >t(r+1,vector<int>(c+1));
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>t[i][j];
            t[r][j]+=t[i][j];
            t[i][c]+=t[i][j];
            t[r][c]+=t[i][j];
        }
    }
        
    for(int i=0;i<=r;i++){
        for(int j=0;j<c;j++){
            cout<<t[i][j]<<" ";
        }
        cout<<t[i][c]<<endl;
    }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cerr << (*begin) << " ";
    *begin++;
  }
  cerr << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cerr << " " << Array[i][j];
    }
    cerr << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int N;
vector<string> vs;
int ans = 0;
int _a = 0, ba = 0, b_ = 0;

void solve() {
  dbg3(_a, ba, b_)
  if (ba == 0) {
    ans += min(_a, b_);
    cout << ans << endl;
    return;
  }

  if (_a and ba and b_) {
    // ans += ba - 1;
    // ans += (ba + 2)-1;
    // ans += max(0ll,min(_a-1, b_-1));
    ans += ba + 1;
    _a--, b_--;
    ans += max(0ll, min(_a, b_));
  dbg("bb")
  } else if ((_a and ba and !b_) or (!_a and ba and b_)) {
    ans += ba;
  dbg("cc")
  } else {
    ans += max(0ll, ba-1);
  dbg("dd")
  }

  cout << ans << endl;
}

signed main() {
  cin >> N;
  rep (i, N) {
    string s;
    cin >> s;
    vs.push_back(s);
    int cnt = 0;
    rep (j, s.size()-1) {
      if (s[j] == 'A' and s[j+1] == 'B') {
        cnt++;
      }
    }
    ans += cnt;

    if (s.front() == 'B' and s.back() == 'A') {
      ba++;
    }
    if (s.front() != 'B' and s.back() == 'A') {
      _a++;
    }
    if (s.front() == 'B' and s.back() != 'A') {
      b_++;
    }
  }

  solve();

  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define UL unsigned int
#define ULL unsigned long long int
#define LI long int
#define LL long long
#define LF double
#define LLF long double
#define FOR(a,b,c) for(a=b;a<=c;a++)
#define rFOR(a,b,c) for(a=b;a>=c;a--)
#define pb push_back
#define mp make_pair
#define IOF ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int MOD1=1000000007;
int binoMax=10000;
vector<LL> numInv(binoMax+1),factNumInv(binoMax+1),fact(binoMax+1);
// If needed call this function for generating ncrmodp
inline void generate_ncrp(LL p){
	int i;
	numInv[0]=numInv[1]=1;
	FOR(i,2,binoMax){
		numInv[i]=numInv[p%i]*(p-p/i)%p;
	}
	factNumInv[0]=factNumInv[1]=1;
	FOR(i,2,binoMax){
		factNumInv[i]=(numInv[i]*factNumInv[i-1])%p;
	}
	fact[0]=1;
	FOR(i,1,binoMax){
		fact[i]=(fact[i-1]*i)%p;
	}
}
// calculates C(n,r)%p in O(1) for many queries
LL ncrmodp(LL n,LL r,LL p){
	LL ans = ((fact[n]*factNumInv[r])%p*factNumInv[n-r])%p;
	return ans;
}

LL expmodp(LL x,LL y,LL p){
	LL res = 1;
	while(y>0){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

int main(){
	IOF
	LL N,i,j,k,ans=0;
	cin>>N;
	FOR(i,1,N){
		for(j=1;i*j<(N);j++){
			ans++;
		}
	}
	cout<<ans<<endl;
return 0;
}

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

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

int main () {
    double D, T, S;
    cin >> D >> T >> S;
    if (D/S <= T) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int ans = 0;
  REP(i, N) {
    cin >> a[i];
    ans += a[i] - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256