akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

int f(int b, int n){
    if(n < b) return n;
    return f(b, n / b) + (n % b);
}

signed main(){

    int n, s; cin >> n >> s;
    int ans = -1;
    
    int b = 2;
    while(b * b <= n){
        if(f(b, n) == s){
            ans = b;
            break;
        }
        b++;
    }

    if(ans == -1 && n > s){
        IFOR(a, 1, b){
            if((n - s) % a == 0){
                int b0 = 1 + (n - s) / a;
                if(f(b0, n) == s){
                    ans = b0;
                    break;
                }
            }
        }
    }else if(ans == -1 && n == s){
        ans = n + 1;
    }

    cout << ans;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	N, Q = map(int, input().split())
	S = "_" + input() + "_"
	
	TD = []
	for _ in range(Q):
		tmp = input().split(" ")
		t = tmp[0]
		d = tmp[1]
		TD.append((t, d))
		
	TD.reverse()
	gake_L = 0
	gake_R = N - 1 + 2
	
	for i, val in enumerate(TD):
		t, d = val
		
		if d == "R":
			if t == S[gake_R-1]:
				gake_R -= 1
			if t == S[gake_L]:
				gake_L -= 1
		
		if d == "L":
			if t == S[gake_R]:
				gake_R += 1
			if t == S[gake_L+1]:
				gake_L += 1
	
	print(max(0, gake_R-gake_L-1))
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 18480
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=10000000;

vector<LL> pdivi(LL K){
    vector<LL> v;
    for(LL i=2;i*i<=K;i++){
        if(K%i) continue;
        v.pb(i);
        while(K%i==0){
            K/=i;
        }
    }
    if(K!=1) v.pb(K);
    return v;
}



int main(){
    LL N,P;cin >> N >> P;
    auto t=pdivi(P);
    LL ans=1;
    for(int i=0;i<t.size();i++){
        int k=0;
        while(P%t[i]==0){
            P/=t[i];
            k++;
        }
        for(int j=0;j<k/N;j++) ans*=t[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    int[] a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    br.close();
    long sum = 0;
    int prev = a[0];
    for(int i = 1; i < n; i++){
      if(prev > a[i]) {
        sum += (long)prev - a[i];
      }
      prev = Math.max(prev, a[i]);
    }
    System.out.println(sum);
  }
}

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

long long waru(long long x){
    long long y=0;
    while(x%2==0){
        y++;
        x/=2;
    }
    return y;
}

int main(void){
    long long N;cin>>N;
    long long A[N];
    long long ans=pow(10,9);
    for(long long i=0;i<N;i++){
        cin>>A[i];
        ans=min(waru(A[i]),ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define modd 998244353
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
ar<lld,2> arr[300000];
map<ar<lld,3>, lld> ma;
lld fastpower(lld x, unsigned lld y, lld p)
{
    lld res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
     ios;
     lld TESTS,q,a,s,b,l,r,c,k,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
     //cin>>TESTS;
     while(TESTS--)
     {
         cin>>n;
         rep(i,0,n-1)cin>>arr[i][0]>>arr[i][1];
         lld cou=0;
         rep(i,0,n-1) rep(j,i+1,n-1){
            x=arr[i][0]-arr[j][0];
            y=arr[i][1]-arr[j][1];
            z=arr[i][1]*x-arr[i][0]*y;
            lld g=__gcd(abs(x),abs(y));
            g=__gcd(g,abs(z));
            x/=g;y/=g;z/=g;
            if (ma[{x,y,z}]) continue;
            ma[{x,y,z}]=1;
            ma[{-x,-y,-z}]=1;
            lld now=2;
            rep(k,0,n-1){
                if(k==i||k==j)continue;
                xs=arr[k][0]-arr[i][0];
                ys=arr[k][1]-arr[i][1];
                if (xs*y==ys*x)now++;
            }
            cou+=fastpower(2,now,modd);
            cou%=modd;
            cou+=modd-1;
            cou%=modd;
            cou+=modd-now;
            cou%=modd;
         }
      //   cout<<cou<<"\n";
      lld ans=fastpower(2,n,modd);
      ans+=modd-1;
      ans%=modd;
      ans+=modd-cou;
      ans%=modd;
      ans+=modd-n;
      ans%=modd;
         cout<<ans;
     }
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<int> a;
    int temp;

    for (int i = 0; i < 200000; i++) {
        a.push_back(0);
    }

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

    for (int i = 0; i < n; i++) {
        cout << a[i] << "\n";
    }
    



    return 0;
}

Measured memory_bytes: 4320
/*
 * atcoder/dp_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long
#define MOD 10e9+7

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
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; }

const int MAX_N = 101;
int N, CAP;
ll V[MAX_N];
int W[MAX_N];
ll dp[110][100200];

void input() {
  cin >> N >> CAP;
  loop(n,0,N) {
    cin >> W[n] >> V[n];
  }
}

void solve() {
  memset(dp, 0, sizeof(dp));
  for (int cap=1; cap<=CAP; cap++) {
    for (int n=1; n<=N; n++) {
      chmax(dp[n][cap], dp[n-1][cap]);
      ll v = V[n-1]; int w = W[n-1];
      if (w > cap) continue;
      chmax(dp[n][cap], dp[n-1][cap-w] + v);
    }
  }
  cout << dp[N][CAP] << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 86400
n, a, b, c, d = map(int, input().split())
s = input()

if c < d:
  if "##" in s[a:c] or "##" in s[b:d]:
    print("No")
  else:
    print("Yes")
else:
  if "##" in s[:c]:
    print("No")
  else:
    if "..." in s[b-2:d+1]:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 3572
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){

    int n;
    string s;
    IN n >> s;
    int ans = 0;
    rep(i,0,n-1){
	set<char> l,r;
	
	rep(j,0,i+1)l.it(s[j]);
	rep(j,i+1,n)r.it(s[j]);
	int cnt = 0;

	for(auto ite:l){
	    if(r.count(ite) != 0)cnt++;
	}
	
	ans = max(ans,cnt);
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

// IO struct
type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func newIO() *IO {
	return &IO{
		scanner: bufio.NewScanner(os.Stdin),
		writer:  bufio.NewWriter(os.Stdout),
	}
}

func (IO *IO) nextLine() string {
	IO.scanner.Scan()
	return IO.scanner.Text()
}

func (IO *IO) nextInt() int {
	i, e := strconv.Atoi(IO.nextLine())
	if e != nil {
		panic(e)
	}
	return i
}

func (IO *IO) scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		num = IO.nextInt()
		nums = append(nums, num)
	}
	return
}

func (IO *IO) printLn(a ...interface{}) {
	fmt.Fprintln(IO.writer, a...)
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func sumSlice(nums []int) int {
	sum := 0
	for _, n := range nums {
		sum += n
	}
	return sum
}

func binarySearch(target int, list []int) int {
	left := 0
	right := len(list) - 1
	mid := (left + right) / 2

	for {
		if list[mid] < target {
			left = mid + 1
		} else {
			right = mid
		}
		mid = (left + right) / 2
		if left >= right {
			break
		}
	}
	return mid
}

var io = newIO()

func main() {
	io.scanner.Split(bufio.ScanWords) // switch to separating by space
	// scanner.Buffer([]byte{}, 1000000009) // switch to read large size input
	defer io.writer.Flush()

	nums := io.scanNums(3)
	sort.Ints(nums)

	totalDiff := 0
	totalDiff += nums[2] - nums[0]
	totalDiff += nums[2] - nums[1]

	answer := 0
	if totalDiff%2 == 0 {
		answer = int(totalDiff / 2)
	} else {
		totalDiff++
		answer = 1 + int(totalDiff/2)
	}

	io.printLn(answer)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  vector<ll> x = {};
  x.resize(n, 0);

  for (auto i = 1; i < n; i++)
  {
    ll a;
    cin >> a;
    x[a - 1]++;
  }

  for (auto i = 0; i < n; i++)
  {
    cout << x[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 4844
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var PQR = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        var ans = PQR.OrderBy(x => x).Take(2).Sum();

        WriteLine(ans);
    }
}


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

int main(){
  int n,k,a;
  cin >> n >>k;
  int min =1;
  for (a=0;a<n;a++){
    if (min*2 >= (min +k)){
      min +=k;
    }else{
      min *= 2;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i = 0; i < N; ++i)
        cin >> p[i];
    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < K; ++i)
        ans += p[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>

int main(){
  double n;
  std::cin >> n;

  double ret = 0;
  if((int)n % 2 == 0) ret = 0.5;
  else {
    ret = ((int)n/2 + 1) / n;
  }

  std::cout << ret << std::endl;
   
  return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int,int> mp;
    while(N--) {
        int A;
        cin >> A;
        mp[A]++;
    }

    int ans = 0;
    for(auto e: mp) {
        if(e.second >= e.first) {
            ans += e.second - e.first;
        } else {
            ans += e.second;
        }
    }

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


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

int main (void) {
    int N;
    priority_queue<int, vector<int>, greater<int>> A;

    cin >> N;
    for (int i = 0; i < N; i++) {
       int a;
       cin >> a;
       A.push(a);
    }

    while (A.size() > 1) {
        int a = A.top();
        A.pop();

        int b = A.top();
        A.pop();

        if (b % a > 0) A.push(b % a);
        A.push(a);
    }

    cout << A.top() << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i = 0;i < n;i ++){
        cin >> p.at(i);
    }

    int s = 0;
    for(int i = 0;i < n;i ++){
        if(p.at(i) != i+1){
            s ++;
        }
    }

    if(s != 0 && s != 2){
        cout << "NO" << endl;
        return 0;
    }

    if(s == 0){
        cout << "YES" << endl;
        return 0;
    }

    int a,b;

    for(int i = 0;i < n;i ++){
        if(p.at(i) != i+1){
            a = i;
            break;
        }
    }
    for(int i = a+1;i < n;i ++){
        if(p.at(i) != i+1){
            b = i;
        }
    }

    if(p.at(a) == b+1 && p.at(b) == a+1){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(v) v.begin(), v.end()
#define vl vector<ll>
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=100005;
ll dp[N]={};
void solve()
{
    ll n,m=0,k=0,i=1,j,p,f,x;
    ll ans=0;
    cin>>n>>k;
    ll a[n] = {};
    for(i = 0; i < n; i++) cin>>a[i];
    for(ll stones = 0; stones <= k; stones++)
    {
        for(ll j: a)
        {
            if(stones >= j && !dp[stones - j])
            {
                dp[stones] = true;
            }
        }
    }
    dp[k] ? cout<<"First": cout<<"Second";
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
     #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif 
    int t=1;
    //cin>>t;
    while(t--)solve();
    return 0;
}

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

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

Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
    int month, day,t;
    cin >> month>> day;
    t=month-1;
    if(day>=month){
        t=t+1;
    }
    else{
        t=t+0;
    }
    printf("%d",t);
    

    
}


Measured memory_bytes: 3760
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 300005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
#define x1 fkaod
#define y1 dajosk
#define x2 fdsojfs
#define y2 vdijsfjs
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,k;
P a[MAXN];
int x1,y1,x2,y2;
vector<int> x,y;
vector<P> v;
int dp[MAXN];
void find(int &k,vector<int> &a)
{
    k=lower_bound(a.begin(),a.end(),k)-a.begin()+1;
}
bool cmp(P p,P q)
{
    return abs(p.S-y1)<abs(q.S-y1);
}
const double PI=acos(-1.0);
int main()
{
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    int s=abs(x1-x2)+abs(y1-y2);
    int rg=min(abs(x1-x2),abs(y1-y2));
    x.push_back(x1);x.push_back(x2);y.push_back(y1);y.push_back(y2);
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i].F,&a[i].S);
        x.push_back(a[i].F);y.push_back(a[i].S);
    }
    sort(x.begin(),x.end());sort(y.begin(),y.end());
    x.erase(unique(x.begin(),x.end()),x.end());y.erase(unique(y.begin(),y.end()),y.end());
    find(x1,x);find(x2,x);find(y1,y);find(y2,y);
    for(int i=0;i<n;i++) {find(a[i].F,x);find(a[i].S,y);}
    if(x1>x2) {swap(x1,x2); swap(y1,y2);}
    for(int i=0;i<n;i++) if(a[i].F>=min(x1,x2)&&a[i].F<=max(x1,x2)&&a[i].S>=min(y1,y2)&&a[i].S<=max(y1,y2)) v.push_back(a[i]);
    sort(v.begin(),v.end(),cmp);
    //printf("%d\n",(int)v.size());
    //printf("%d %d %d %d\n",x1,y1,x2,y2);
    //for(int i=0;i<(int)v.size();i++) printf("%d %d\n",v[i].F,v[i].S);
    fill(dp,dp+(int)v.size(),INF);
    for(int i=0;i<(int)v.size();i++) *lower_bound(dp,dp+(int)v.size(),v[i].F)=v[i].F;
    int k=lower_bound(dp,dp+(int)v.size(),INF)-dp;
    //printf("%d\n",k);
    if(k==rg+1) printf("%.15f\n",100.0*s-20.0*k+5*PI*(k-1)+10*PI);
    else printf("%.15f\n",100.0*s-20.0*k+5*PI*k);
    return 0;
}



Measured memory_bytes: 5864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>za; int a[200005],n; vector<int>c[200005]; ll ans[200005];
int main(){
	cin>>n;
	repn(i,n){cin>>a[i];za.pb(a[i]);}
	SORT(za);ERASE(za);
	repn(i,n){a[i]=POSL(za,a[i]);c[a[i]].pb(i);}
	int f = INF,cnt = 0;
	for(int i=za.size()-1;i>=0;i--){
		rep(j,c[i].size()) f = min(c[i][j],f);
		cnt += c[i].size();
		ans[f] += 1LL*cnt*(i?(za[i]-za[i-1]):za[i]);
	}
	repn(i,n) printf("%lld\n",ans[i]);
}

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

typedef long long ll;


int 
main(void)
{
  ll tmp = (24 - 14) /7;
  bool aaa = tmp < 4 -1;
  cout << aaa << endl;

  
}
*/

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

typedef long long ll;



int main() {


  char c; cin >> c;
  if((int)c < 97) cout << 'A' << endl;
  else cout << 'a' << endl;

}


Measured memory_bytes: 3584
S = input()
n = len(S)

ans = 0
for i in range(1,n+1):
    for j in range(n-i+1):
        target = S[j:j+i]
        flag = True
        for t in target:
            if t not in ['A', 'C', 'G', 'T']:
                flag = False
                break
            
        if flag:
            ans = max(ans, len(target))

print(ans)


Measured memory_bytes: 3060
from collections import deque
h, w = map(int, input().split())
C = [list(input()) for _ in range(h)]
black_cells = 0
for y in range(h):
    for x in range(w):
        if C[y][x] == '#':
            black_cells += 1

dist = [[-1] * w for _ in range(h)]
dist[0][0] = 0
que = deque()
que.append((0, 0))
flag = False

while len(que) > 0:
    now_y, now_x = que.popleft()
    now_dist = dist[now_y][now_x]
    for dy, dx in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        next_y = now_y + dy
        next_x = now_x + dx
        if 0 <= next_y < h and 0 <= next_x < w:
            if dist[next_y][next_x] == -1 and C[next_y][next_x] != '#':
                que.append((next_y, next_x))
                dist[next_y][next_x] = now_dist + 1
        if dist[h - 1][w - 1] != -1:
            flag = True
            break
    if flag:
        break

if flag:
    print(h * w - black_cells - dist[h - 1][w - 1] - 1)  # 全体のマス - 最初から黒い地点 - 最短経路 - スタート地点（ゴールは最短経路に含まれている）
else:
    print('-1')

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	string s;
  cin >> s;
  dep(i, s.size() - 1, 0) cout << s[i];
  cout << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <cstdlib>

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<string, int> si;
const int INF = 1 << 29;
const int MAX = 100000;
#define mp make_pair
#define fi first
#define se second

int main() {
    ios::sync_with_stdio(false);
    int n;
    int data[105];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    int ans = INF;
    for (int y = -100; y <= 100; y++) {
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += (data[i] - y) * (data[i] - y);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#include<limits>
#include<bitset>
#include<ctype.h>
#include<set>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007LL;
const ll INF=1000000000;
const int MAX=100001;
struct edge{int to,cost;};
typedef pair<int,int> P;
int main(){
    string s;
    cin>>s;
    int sl=s.length();
    int t=0;
    int ac=0;
    bool f=true;
    for(int i=0;i<sl;i++){
        if(t==0){
            if(s[i]=='A'){
                ac++;
                if(ac>1){
                    f=false;
                }
            }else if(s[i]=='K'){
                t++;
                ac=0;
            }else{
                f=false;
            }
        }else if(t==1){
            if(s[i]=='I'){
                t++;
                ac=0;
            }else{
                f=false;
            }
        }else if(t==2){
            if(s[i]=='H'){
                t++;
                ac=0;
            }else{
                f=false;
            }
        }else if(t==3){
            if(s[i]=='A'){
                ac++;
                if(ac>1){
                    f=false;
                }
            }else if(s[i]=='B'){
                t++;
                ac=0;
            }else{
                f=false;
            }
        }else if(t==4){
            if(s[i]=='A'){
                ac++;
                if(ac>1){
                    f=false;
                }
            }else if(s[i]=='R'){
                t++;
                ac=0;
            }else{
                f=false;
            }
        }else if(t==5){
            if(s[i]=='A'){
                ac++;
                if(ac>1){
                    f=false;
                }
            }else{
                f=false;
            }
        }
        if(!f){
            break;
        }
        
    }
    if(t<5){
        f=false;
    }
    if(f){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    getchar();
    getchar();
}

                           


Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        int kazu = int.Parse(ReadLine());
        int[] ans = new int[2];
        ans[1] = 1;
        for(int i=1;i<=kazu;i++){
            int k = i;
            int count = 0;
            for(int j=0;j<10;j++){
                if(k%2==0){
                    k/=2;
                    count++;
                }else{
                    break;
                }
            }
            if(count>ans[0]){
                ans[0]=count;
                ans[1]=i;
            }
        }
        WriteLine("{0}",ans[1]);
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 1010






int main() {
	int a[N][N];
	vector<int> b[1000000];
	int c[1000000];
	int d[1000000];
	queue<int>q;
	f(i, 1000000) {
		c[i] = 0;
		d[i] = 0;
	}
	int n, k;
	int x, y,xx,yy, z,zz;
	int s, ans;
	bool v = true;
	ans = 1;
	scanf("%d", &n);
	f(i, n) {
		f(j, n - 1) {
			scanf("%d", &a[i][j]);
		}
	}
	f(i, n) {
		f(j, n - 2) {
			x = i;
			y = a[i][j]-1;
			xx = i;
			yy = a[i][j + 1]-1;
			if (x > y) {
				swap(x, y);
			}
			if (xx > yy) {
				swap(xx, yy);
			}
			z = (x * 1000) + y;
			zz = (xx * 1000) + yy;
			b[z].push_back(zz);
			c[zz]++;
		}
	}

	f(i, 1000000) {
		if (c[i] == 0) {
			q.push(i);
			d[i] = 1;
		}
	}
	while (!q.empty()) {
		x = q.front();
		q.pop();
		f(i, b[x].size()) {
			c[b[x][i]]--;
			d[b[x][i]] = max(d[x] + 1, d[b[x][i]]);
			if (c[b[x][i]] <= 0) {
				ans = max(ans, d[b[x][i]]);
				q.push(b[x][i]);
			}
		}
	}
	v = true;
	f(i, 1000000) {
		if (c[i] != 0)v = false;
	}

	if(v)printf("%d\n", ans);
	else printf("-1");


	return 0;
}

Measured memory_bytes: 53120
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int N, L[100];

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

	int k, lmax=0;
	for(int i=0; i<N; i++){
		if(L[i]>lmax){
			lmax = L[i];
			k = i;
		}
	}
	int lsum=0;
	for(int i=0; i<N; i++){
		if(i==k) continue;
		lsum += L[i];
	}

	cout << (lsum > lmax?"Yes":"No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double
#define PI 3.14159265358979323846264338327950L

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);

	long double rsq = (long double)(a * a + b * b) - (long double)(2 * a *b) * cosl(rad);
	
	printf("%20.20Lf\n", sqrtl(rsq));
	return 0;
}

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

int main(){
   
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2) {
        int sum = 0;
        for(int j = 1; j <= i; j += 2) {
            if(i % j == 0) sum++;
        }
        if(sum == 8) ans++;
    }

    cout << ans;
    return 0;
}

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

int n, m;
bool g[8][8];

int dfs(int v, int n, bool visited[8]) {
  bool all_visited = true;

  for (int i = 0; i < n; i ++) {
    if (visited[i] == false) all_visited = false;
  }

  if (all_visited) return 1;

  int ret = 0;
  for (int i = 0; i < n; i ++) {
    if (g[v][i] == false) continue;
    if (visited[i]) continue;

    visited[i] = true;
    ret += dfs(i, n, visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i ++) {
    int x, y;
    cin >> x >> y;
    x --, y --;
    g[x][y] = true, g[y][x] = true;
  }

  bool visited[8];
  for (int i = 0; i < n; i ++) visited[i] = false;

  visited[0] = true;

  cout << dfs(0, n, visited) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
char s[111][111];
const int h = 100;
const int w = 100;
bool vis[111][111];

int inside(int x, int y) {
	return (0 <= x && x < h) && (0 <= y && y < w);
}
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void dfs(int x, int y) {
	vis[x][y] = true;
	for(int i = 0; i < 4; i++) {
		int p = x + dx[i];
		int q = y + dy[i];
		if(inside(p, q) && s[p][q] == s[x][y] && vis[p][q] == false) {
			dfs(p, q);
		}
	}
}

int main(int argc, char const *argv[])
{
	memset(s, '&', sizeof s);
	int A, B;
	cin >> A >> B;
	bool bad = false;
	if(A > B) {
		swap(A, B);
		bad = true;
	}
	A--;
	int cntA = 0;
	int cntB = 0;
	for(int i = 0; i < h; i++) {
		if(A == cntA) {
			for(int j = 0; j < w; j++) {
				s[i][j] = '#';
			}
			break;
		}
		for(int j = 0; j < w; j++) {
			if(A == cntA) {
				for(int k = j; k < w; k++) {
					s[i][k] = '#';
				}
				break;
			}
			if((i + j) % 2 == 0) {
				s[i][j] = '.';
				++cntA;
			} else {
				s[i][j] = '#';
				++cntB;
			}
		}
	}
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(s[i][j] == '&') {
				s[i][j] = '.';
			}
		}
	}

	int fa = 0;
	int fb = 0;

	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(vis[i][j] == false) {
				dfs(i, j);
				if(s[i][j] == '.') ++fa;
				else ++fb;
			}
		}
	}
	// cout << fa << " " << fb << endl;
	// assert(fa == A);
	for(int i = h-1; i >= 0; i -= 2) {
		if(fb == B) break;
		for(int j = 0; j < w; j += 2) {
			if(fb == B) break;
			s[i][j] = '#';
			++fb;
		}
	} 
	// cout << fb << endl;
	cout << h << " " << w << endl;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			if(bad) s[i][j] = (s[i][j] == '#') ? '.' : '#';
			cout << s[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#define ll long long
using namespace std;
const int N=4007;
const int mod=998244353;
template <class I>
inline void read(I &x){
    int f=1;
    char c;
    for(c=getchar();c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
    for(x=0;c>='0'&&c<='9';x=(x<<3)+(x<<1)+(c&15),c=getchar());
    x*=f;
}
int n,k,C[N][N],jc[N];
void pre(){
	C[0][0]=1;
	for(int i=1;i<=n+k;i++){
		C[i][0]=1;
		C[i][i]=1;
		for(int j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	jc[0]=1;
	for(int i=1;i<=n+k;i++) jc[i]=1ll*jc[i-1]*2%mod;
}
int main(){
	read(k),read(n);
	pre();
	for(int i=2;i<=2*k;i++){
		int ans=0;
		int m=0;
		for(int j=1;j<i;j++)
			if(i-j<=k&&i-j>j) ++m;
		if(i%2) 
			for(int j=0;j<=m;j++)
				ans=(ans+1ll*jc[j]*C[m][j]%mod*C[n+k-2*m-1][k-2*m+j-1]%mod)%mod;
		else for(int j=0;j<=m;j++)
			ans=(ans+1ll*jc[j]*C[m][j]%mod*(C[n+k-2*m-2][k-2*m+j-2]+C[n+k-2*m-3][k-2*m+j-2])%mod)%mod;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 48248
#include<iostream>
#include<algorithm>
using namespace std;
int n;
string s[1111];
int m=-2e9,M=2e9;
main()
{
	while(cin>>n,n)
	{
		for(int i=1;i<=n;i++)cin>>s[i];
		int f=m,l=M;
		for(int i=1;i<=n;i++)
		{
			if(i%2)
			{
				if(s[i]=="x")
				{
					if(i>1)
					{
						if(s[i-1]=="x")
						{
							l=f-1;
							break;
						}
						else
						{
							l=min(l,stoi(s[i-1])-1);
						}
					}
					if(i<n)
					{
						if(s[i+1]=="x")
						{
							l=f-1;
							break;
						}
						else
						{
							l=min(l,stoi(s[i+1])-1);
						}
					}
				}
				else if(i>1&&s[i-1]!="x"&&stoi(s[i-1])<=stoi(s[i])
					||i<n&&s[i+1]!="x"&&stoi(s[i+1])<=stoi(s[i]))
				{
					l=f-1;
					break;
				}
			}
			else
			{
				if(s[i]=="x")
				{
					if(i>1)
					{
						if(s[i-1]=="x")
						{
							f=l+1;
							break;
						}
						else
						{
							f=max(f,stoi(s[i-1])+1);
						}
					}
					if(i<n)
					{
						if(s[i+1]=="x")
						{
							f=l+1;
							break;
						}
						else
						{
							f=max(f,stoi(s[i+1])+1);
						}
					}
				}
				else if(i>1&&s[i-1]!="x"&&stoi(s[i-1])>=stoi(s[i])
					||i<n&&s[i+1]!="x"&&stoi(s[i+1])>=stoi(s[i]))
				{
					f=l+1;
					break;
				}
			}
		}
		if(f<l)cout<<"ambiguous"<<endl;
		else if(f>l)cout<<"none"<<endl;
		else cout<<f<<endl;
	}
}



Measured memory_bytes: 3184
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double
const int mod=1000000007;
using namespace std;

int main(void){
  int n;
  cin>>n;
  map<int,int> countmp_odd;
  map<int,int> countmp_even;
  int input;
  FOR(i,0,n){
    cin>>input;
    countmp_odd[input]++;
    i++;
    if(i==n) break;
    cin>>input;
    countmp_even[input]++;
  }
  set< pair<int,int> > maxset_odd;
  set< pair<int,int> > sec_maxset_odd;
  int max_o = 0;
  int sec_max_o = 0;
  for(auto x:countmp_odd){
    if(x.ND>max_o){
        sec_max_o = max_o;
      max_o=x.ND;
    }else if(x.ND>sec_max_o){
      sec_max_o=x.ND;
    }
  }
  
  for(auto x:countmp_odd){
    if(x.ND==max_o) maxset_odd.insert(x);
    if(x.ND==sec_max_o) sec_maxset_odd.insert(x);
  }
  set< pair < int,int > > maxset_even;
  set< pair < int,int > > sec_maxset_even;
  int max_e=0;
  int sec_max_e=0;
  for(auto x:countmp_even){
    if(x.ND>max_e){
        sec_max_e = max_e;
      max_e=x.ND;
    }else if(x.ND>sec_max_e){
      sec_max_e=x.ND;
    }
  }
  for(auto x:countmp_even){
    if(x.ND==max_e) maxset_even.insert(x);
    if(x.ND==sec_max_e) sec_maxset_even.insert(x);
  }

  //順序対の集合maxset_oddと集合maxset_evenの元を比較して，それぞれの元の左の要素が相異なるようにそれぞれ一つずつ元を選ぶ
   //cout<<"max_o :\t"<<max_o<<endl;
   //cout<<"sec_max_o :\t"<<sec_max_o<<endl;
   //cout<<"max_e :\t"<<max_e<<endl;
   //cout<<"sec_max_e :\t"<<sec_max_e<<endl;
  int flag=0;
  for(auto x:maxset_even){
    for(auto y:maxset_odd){
      if(x.ST!=y.ST){
        flag=1;
        // cout<<"pattern 1"<<endl;
        cout<<n-x.ND-y.ND<<endl;  return 0; break;
      }
    }
  }
  if(flag==0){
    if(max_o==max_e && max_e==n/2){
      // cout<<"pattern 2"<<endl;
      cout<<n/2<<endl;
    }else{
      // cout<<"pattern 3"<<endl;
      cout<<n-max(max_o+sec_max_e,sec_max_o+max_e)<<endl;
    }
  }
  // if(maxset_even.size()==1 && maxset_odd.size()==1 && (*(maxset_even.begin())).ST==(*(maxset_odd.begin())).ND ){
  //   cout<<n/2<<endl;
  // }
  return 0;
}


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

int main() {
  int N, K; cin >> N >> K;
  ll ans {};
  for (int i = K + 1; i <= N; i++) {
    ans += (i - K) * (N / i);
    ans += ( (N % i) ? max(0, N % i - K + 1) : 0 );
    ans -= (N % i and !K);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int k;s(k);
	int val = 7;
	
	for(int i = 0;i<k;i++)
	{
		val = val%k;
		if(val == 0)
		{
			cout<<i+1<<endl;return 0;
		}
		val = val*10 + 7;
	}
	
	cout<<"-1"<<endl;
	return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int a, b,c,k,cnt=0;
	cin >> a >> b >> k;
	c = max(a, b);
	for (int i = c; i >= 1;i--) {
		if (a % i == 0 && b % i == 0) cnt++;
		if (cnt == k) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
int main(){
    int sum = 0;
    rep(i,5){
        int tmp;
        scanf("%d",&tmp);
        sum += (tmp > 40) ? tmp : 40;
    }
    printf("%d\n",sum/5);
    return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>
#include<vector>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int cmp(int a,int b){
	return a>b;
}
ll read(){
	ll x=0,w=1;
	char ch=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')
			w=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	return w*x;
}//快读算法
int main(){
   int n;
   cin>>n;
   string a,b;
   cin>>a>>b;
   int f=0;
   for(int  i=0;i<n;i++){
        cout<<a[i]<<b[i];
   }

	return 0;
}




//humuhumunukunuku
//humuhumunukunuku



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string s;
    int cnt = 0;
    while (cin >> s)
    {
        int n = s.size() / 2;
        int m;
        s.size() % 2 == 0 ? m = n : m = n + 1;
        string t_fir = s.substr(0, n);
        string t_sec = s.substr(m);
        reverse(ALL(t_sec));
        
        if (t_fir == t_sec)
            cnt++;
    }
    OP(cnt);
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define N 50001
#define M 100011
#define f first
#define s second
#define INF (1e9)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> PP;
int n,m,T;
set<PP> G[M]; // to,cost,y,x
vector<int> g[M],c[M];
vector<P> D[M];
priority_queue<PP,vector<PP>,greater<PP> >Q;  

void ifPush(int cost,int cnt,int y,int x){
  if(D[y][x]<=P(cost,cnt))return;
  D[y][x]=P(cost,cnt);
  Q.push(PP(D[y][x],P(y,x)));
}

P dijkstra(int a,int b){
  vector<int>used(n,0);

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    int cost=t.f.f,cnt=t.f.s;
    int y=t.s.f, x=t.s.s;
    int pos=g[y][x];
    if(D[y][x]<t.f)continue;
    if(pos==b) return t.f;

    if(used[pos]++){
      if(x+1<g[y].size())ifPush(cost+c[y][x],cnt,y,x+1);
      if(x-1>=0)ifPush(cost+c[y][x-1],cnt,y,x-1);
      continue;
    }
    
    for(set<PP>::iterator i=G[pos].begin();i!=G[pos].end();i++){
      int ncost=cost+i->f.s,ncnt=cnt;
      int ny=i->s.f,nx=i->s.s;
      if(pos!=a&&(ny!=y||abs(x-nx)!=1))ncost+=T,ncnt++;
      ifPush(ncost,ncnt,ny,nx);
    }
  }
  return P(-1,-1);
}

int main(){
  string s,t;
  cin>>m>>T>>s>>t;
  map<string,int> mp;
  mp[s]=n++;
  mp[t]=n++;

  for(int i=0,a;i<m;i++){
    cin>>a;
    D[i].resize(a,P(INF,INF));
    c[i].resize(a-1);
    for(int j=0;j<a;j++){
      string str;
      cin>>str;
      if(!mp.count(str))mp[str]=n++;
      if(str==s)D[i][j]=P(0,0);
      if(str==s&&Q.empty())Q.push(PP(P(0,0),P(i,j)));
      g[i].push_back(mp[str]);
    }

    for(int j=0,pre=g[i][0];j<a-1;j++){
      cin>>c[i][j];
      int pos=g[i][j+1];
      G[pre].insert(PP(P(pos,c[i][j]),P(i,j+1)));
      G[pos].insert(PP(P(pre,c[i][j]),P(i,j)));
      pre=pos;
    }
  }

  P ans=dijkstra(0,1);
  if(ans==P(-1,-1)) cout<<-1<<endl;
  else cout<<ans.f<<" "<<ans.s<<endl;
  return 0;
}

Measured memory_bytes: 37040
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.0001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	ll n, p, w = 1;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	for (ll i = 2; i*i <= p; i++) {
		if (p%i == 0) {
			ll cnt = 1;
			p /= i;
			while (p%i == 0) {
				cnt++;
				p /= i;
				if (cnt == n) {
					w *= i;
					cnt = 0;
				}
			}
		}
	}
	cout << w << endl;
	return 0;
}


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

using namespace std;
int a[100005];
int main()
{
    int n,m,ans=0,mn=1000000000;
    cin >> n >> m;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    for(int i=0;i<n-m+1;i++)
    {
        if(a[i]<0 && a[i+m-1]>0)
        {
            ans=2*min(abs(a[i]),a[i+m-1])+max(abs(a[i]),a[i+m-1]);
        }
        else if(a[i+m-1]<0)
        {
            ans=abs(a[i]);
        }
        else
        {
            ans=a[i+m-1];
        }
        mn=min(mn,ans);
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 768
s=input()
a=int(s[:2])
b=int(s[2:])
if 1<=a<=12 and 1<=b<=12:
    print('AMBIGUOUS')
elif 1<=b<=12:
    print('YYMM')
elif 1<=a<=12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 9120
l, r = map(int, input().split())

num = l % 2019
if r >= l + 2019 - num:
    print(0)

else:
    result = 2019
    for i in range(num, r-l+num):
        for j in range(i+1, r-l+num+1):
            result = min(result, i*j%2019)

    print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N;
int a[200005];

int ball[200005];
int res;
bool ok=true;

signed main(){
    cin>>N;
    for(int i=1;i<=N;++i)cin>>a[i];
    for(int i=N;i>0;--i){
        int cnt=0;
        for(int j=2;;j++){
            if(i*j>N)break;
            cnt+=ball[i*j];
            cnt%=2;
        }
        if(a[i]!=cnt){
            ball[i]+=1;
            res+=1;
            cnt=(cnt+1)%2;
        }
    }
    if(ok){
        cout<<res<<endl;
        for(int i=1;i<=N;++i)if(ball[i]!=0)cout<<i<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin >> n;
  int a[n + 5], ans = 0;
  reps(i, n){
    cin >> a[i];
  }
  reps(i, n){
    if(a[i] == i){
      swap(a[i], a[i + 1]);
      ans ++;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n, m = readmi()
a = readl()
d = defaultdict(int)
k = []
for i in a:
    heapq.heappush(k,(-i, 1))
for i in range(m):
    x, y = readmi()
    heapq.heappush(k,(-y, x))
count = 0
while(n > 0):
    x, y = heapq.heappop(k)
    count += min(y * (-x), n * (-x))
    n = max(n - y, 0)
print(count)

Measured memory_bytes: 96276
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
int main(){
    vector<int> a(26, 0);
    string s;
    while(getline(cin, s)){
        for (auto x: s){
            if (x >= 'a' && x <= 'z') a[x - 'a']++;
            if (x >= 'A' && x <= 'Z') a[x - 'A']++;
        }
        }
        for (int i=0; i<26; i++){
            cout << char('a' + i) << " : " << a[i] << endl;
    }
}


Measured memory_bytes: 3184