akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define mx 1005
#define md 1000000007
using namespace std;

int n, m, a[mx], b[mx], f, af, bf;
long long ans = 1;


int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < m; i++) scanf("%d", &b[i]);
	sort(a, a+n);
	sort(b, b+m);
	for(int i = n*m; i > 0; i--){
		auto ai = find(a, a+n, i);
		auto bi = find(b, b+m, i);
		if(ai == a + n){
			if(bi == b + m){
				ans = ans * f % md;
				f--;
			}else{
				ans = ans * af % md;
				bf++;
				f += af - 1;
			}
		}else{
			if(bi == b + m){
				ans = ans * bf % md;
				af++;
				f += bf - 1;
			}else{
				f += af + bf;
				bf++;
				af++;
			}
		}
	}
	printf("%lld", ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int dp[1000001],Odp[1000001];
int Tn[200],OTn[200]; 
int n = 1000000;

int main(){
    int count = 0;  //pollocks numberの生成
    for(int i = 1;i < 200;i++){
        Tn[i-1] = i * (i + 1) * (i + 2) / 6;
        if(Tn[i-1] % 2 == 1){
            OTn[count] = Tn[i-1];
            count++;
        }
    }

    //個数の初期化
    for(int j = 0;j <= n;j++){
        dp[j] = j;
        Odp[j] = j;
    }
    
    for(int i = 0;i < 200;i++){
        for(int j = OTn[i];j <= n;j++){    //奇数正四面体数の個数の最小値
            if(j >= OTn[i])
                Odp[j] = min(Odp[j],Odp[j-OTn[i]] + 1);
        }
        for(int j = Tn[i];j <= 1000000;j++){    //正四面体数の個数の最小値
            if(j >= Tn[i])
                dp[j] = min(dp[j],dp[j-Tn[i]] + 1);
        }
    }

    //入出力
    while(cin >> n,n)
        cout << dp[n] << ' ' <<  Odp[n] << endl;


    return 0;
}


Measured memory_bytes: 10876
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

# chocoのj列目の0(white)の個数を数える
def count_col_whites(choco, j):
    res = 0
    for c in choco:
        if c[j]=="1":
            res += 1
    return res

# チョコレートをヨコ方向にカットする
def cut_chocolate(i):
    if i == 0:
        return [S]
    else:
        res = []
        pre = 0
        tmp = 0
        while i > 0:
            tmp += 1
            if i%2 == 1:
                res.append(S[pre:tmp])
                pre = tmp
            i //= 2
        res.append(S[pre:len(S)])
        return res

def is_less_than_or_equal_to_K(cut):
    for c in cut:
        for j in range(W):
            tmp = 0
            for i in range(len(c)):
                if c[i][j] == "1":
                    tmp += 1
            if tmp > K:
                return False
    return True

ans = 10**10
for i in range(2**(H-1)):
    # 横方向にカットしたときのかたまりをcutに格納
    cut = cut_chocolate(i)
    tmp_ans = len(cut)-1
    # 縦方向にみていって、1列中の白チョコの個数がK個より大きければそもそも無理
    if not is_less_than_or_equal_to_K(cut):
        continue
    # 縦方向にみていって、白チョコがK個以下のかたまりになるようカットする
    current_white_nums = [0 for _ in range(len(cut))]
    for j in range(W):
        for i in range(len(cut)):
            white_num = count_col_whites(cut[i], j)
            if white_num + current_white_nums[i] <= K:
                current_white_nums[i] += white_num
            else:
                current_white_nums = [count_col_whites(cut[_], j) for _ in range(len(cut))]
                tmp_ans += 1
                break
    ans = min(ans, tmp_ans)
print(ans)




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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int sy,sx,ty,tx;
  cin>>sx>>sy>>tx>>ty;

  string ans;
  rep(_,tx-sx)ans+="R";
  rep(_,ty-sy)ans+="U";
  rep(_,tx-sx)ans+="L";
  rep(_,ty-sy)ans+="D";

  ans+="D";
  rep(_,tx-sx+1)ans+="R";
  rep(_,ty-sy+1)ans+="U";
  ans+="L";
  ans+="U";
  rep(_,tx-sx+1)ans+="L";
  rep(_,ty-sy+1)ans+="D";
  ans+="R";
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func calc(N int, am map[int]struct{}) int64 {
	dp := make([]int64, N+1)
	dp[0] = 1
	dp[1] = 1
	if _, ok := am[1]; ok {
		dp[1] = 0
	}

	for i := 2; i <= N; i++ {
		if dp[i-1] == 0 && dp[i-2] == 0 {
			break
		}

		dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
		if _, ok := am[i]; ok {
			dp[i] = 0
		}
	}

	return dp[N]
}

func main() {
	var N, M int
	fmt.Scanf("%d %d", &N, &M)
	am := map[int]struct{}{}
	for i := 1; i <= M; i++ {
		var a int
		fmt.Scan(&a)
		am[a] = struct{}{}
	}

	ans := calc(N, am)
	fmt.Println(ans % 1000000007)
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int[] L = new int[N];
	static {
		Arrays.setAll(L, i -> Integer.parseInt(sc.next()));
	}
	public static void main(String[] args) {

		Arrays.sort(L);
		int sum = 0;
		for (int i = 0; i < N-1; i++) {
			sum += L[i];
		}
		if (sum>L[N-1]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");

		}
	}
}


Measured memory_bytes: 28500
#include <bits/stdc++.h>
#define pii pair<int,int> 
#define fi first
#define pb push_back
#define si second
#define int   long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define all(o) o.begin(),o.end()
using namespace std;
int32_t main(){	
	int n;
	cin>>n;
	int x=n%10;
	if(x==3)	
		cout<<"bon";
	else if(x==0 || x==1 || x==6 || x==8)
		cout<<"pon";
	else cout<<"hon";
	
	
	
}


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

int main(){
    int n;
    int k;
string name;
cin >> n >> k;
cin >> name;
if(name[k-1]=='A'){
name[k-1]='a';
}
if(name[k-1]=='B'){
name[k-1]='b';
}
if(name[k-1]=='C'){
name[k-1]='c';
}
cout << name << endl;
return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include<algorithm>
#include<map>
#include <vector>
#include<stack>
#include<cstring>

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define ld long double
#define vll vector<ll>
#define vpll vector<pair<ll ,ll > >
#define pb push_back
#define MOD 1000000007
#define inf 100000000000000000
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define fst first
#define scd second
#define fr(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define fr1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define frr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define frab(i,a,b,c) for(ll (i) = a ; (i) < (b) ; (i)+=(c))
#define print(v) for( auto it: v) cout<<it<<" "
#define mst(A) memset( (A) , 0 , sizeof(A) )


//////////////////////////////////////////////////////////////////////////
//------------------TRACE--------------------------------//
template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T>& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        if (i)os << ", ";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
//////////////////////////////////////////////////////

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if (a.first == b.first)
        return (a.scd >= b.scd);
    return (a.first < b.first);
}
vll primes;
vll seive;
void Seive(ll n) {
    seive.resize(n + 5, 1);
    seive[1] = 0, seive[0] = 0;
    for ( int i = 2; i * i < n + 5; i++) {
        if (seive[i]) {
            for (int j = 2 * i; j < n + 5; j += i) {
                seive[j] = 0;
            }
        }
    }
}
ll power(ll x, ll y , ll m = MOD) {
    long long int res = 1;
    x = x % m;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}
ll modinv(ll x , ll mod = MOD) {
    return power(x , mod - 2 , mod);
}
int n, m;
ll A[300060];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int  k, t, a, b, c, d;
    t = 1;

    long double pi = 1.0 * 22 / (long double)7;
    while (t--) {

        //cin>>n>>m;
        cin >> n;
        // Comment the above line  before array input
        cout << n * 2.0 * pi << endl;


    }

}








Measured memory_bytes: 3816
#include <stdio.h>

int main(void) {
  int turu = 2;
  int tart = 4;
  int x, y;
  int judge = 0;
  scanf("%d%d", &x, &y);
  for(int i = 1; i <= x; i++) {
    if(turu * i + tart * (x-i) == y) {
      judge = 1;
    } else if(tart * i + turu * (x-i) == y) {
      judge = 1;
    }
  }
  if(judge == 1) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>
#define L(_i,_N) for(int _i=0;_i<_N;_i++)
typedef long long int lli;
using namespace std;

int main() {
	int N,Line[3];
	cin >> N;
	L(i, N) {
		L(j, 3) cin >> Line[j];
		sort(Line, Line + 3);
		if (pow(Line[0], 2) + pow(Line[1], 2) == pow(Line[2], 2)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
#define MOD 1000000007
const int N = 3002;
double dp[N][N];
double ar[N];
int n;

double F(int pos, int head){
  if (pos >= n){
    if (head > (n - head)){
      return 1;
    }
    return 0;
  }
  if (dp[pos][head] != -1)
    return dp[pos][head];
  double x = F(pos + 1, head + 1) * ar[pos];
  double y = F(pos + 1, head) * (1 - ar[pos]);
  return dp[pos][head] = x + y;
}

int main()
{
  FASTER;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      dp[i][j] = -1;
    }
  }
  cout << fixed << setprecision(10);
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  cout << F(0, 0) << '\n';
  return 0;
}


Measured memory_bytes: 70912
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;


int main() {

    int n, k;
    cin >> n >> k;

    int d = 1;
    int count = 0;

    while(d <= n) {

        d *= k;
        count++;

    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def char(c, N):
  n = ord(c) - ord('A')
  return chr((n + N) % 26 + ord('A'))

def main():
  N = readInts()[0]
  S = input()

  ans = ""
  for c in S:
    ans += char(c, N)
  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3060
using System;

namespace ITP1_2_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strAry = Console.ReadLine().Split(' ');
            int[] intAry = new int[5];
            intAry[0] = int.Parse(strAry[0]);
            intAry[1] = int.Parse(strAry[1]);
            intAry[2] = int.Parse(strAry[2]);
            intAry[3] = int.Parse(strAry[3]);
            intAry[4] = int.Parse(strAry[4]);

            int a, b;
            if (intAry[2] >= 0)
            {
                a = intAry[2] + intAry[4];
            }
            else
            {
                Console.WriteLine("No");
                return;
            }


            if (intAry[3] >= 0)
            {
                b = intAry[3] + intAry[4];
            }
            else
            {
                Console.WriteLine("No");
                return;
            }


            if (a <= intAry[0])
            {
                if (b <= intAry[1])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}

Measured memory_bytes: 8876
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let ans = std::cmp::max(0, a - b*2);
        
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MAX_N = 100000;

// vector<int> dp(100000, 1e9);

int main()
{
    ll A, B,C;
    cin >> A >> B>>C;
    // scanf("%lld%lld", &A,&B);
    if(A==B){
        if(B!=C){
       printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if(B==C){
        if(B!=A){
       printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if(A==C){
        if(B!=C){
       printf("Yes");
        }
        else
        {
    printf("No");
    
        }
        
    }
    else
    printf("No");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;
int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	ll n, m, h, w, X;
	ll k;
	ll insuusyurui[1000] = {};
	ll insuukazu[1000] = {};
	ll memo[4000] = {};
	ll memo2[4000] = {};
	string s;
	cin >> n;
	ll v1[100005] = {};
	ll v2[100005] = {};
	for (int i = 0; i < n / 2; i++)
	{
		cin >> a;
		cin >> b;
		v1[a]++;
		v2[b]++;
	}
	a = 0;
	ll e1 = 0, f1 = 0;
	for (int i = 1; i <= 100000; i++)
	{
		if (a < v1[i])
		{
			a = v1[i];
			c = i;
		}
	}
	v1[c] = 0;

	for (int i = 1; i <= 100000; i++)
	{
		if (e < v1[i])
		{
			e = v1[i];
		}
	}
	b = 0;
	for (int i = 1; i <= 100000; i++)
	{
		if (b < v2[i])
		{
			b = v2[i];
			d = i;
		}
	}
	v2[d] = 0;
	for (int i = 1; i <= 100000; i++)
	{
		if (f < v2[i])
		{
			f = v2[i];
		}
	}
	/*cout << endl;
	cout <<  endl;
	cout <<a << endl;
	cout << b<< endl;
	cout << e<< endl;
	cout << f<< endl;*/

	if (c == d)
	{
		if (a > b)
		{
			if (e + b > a + f)
			{
				cout << n - e - b << endl;
				return 0;
			}
			else
			{
				cout << n - a - f << endl;
				return 0;
				//b = 0;
				//for (int i = 1; i <= 100000; i++)
				//{
				//	if (b < v2[i])
				//	{
				//		b = v2[i];
				//		d = i;
				//		v2[i] = 0;
				//	}
				//}
			}
		}
		else
		{
			if (a + f > b + e)
			{
				cout << n - a - f << endl;
				return 0;
			}
			else
			{
				cout << n - b - e << endl;
				return 0;
				//a = 0;
				//for (int i = 1; i <= 100000; i++)
				//{
				//	if (a < v1[i])
				//	{
				//		a = v1[i];
				//		c = i;
				//		v1[i] = 0;
				//	}
				//}
			}
		}
	}

	cout << n - a - b << endl;

	//cout << sum << endl;
	//cout <<  endl;

	return 0;
}

//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}




//
//ll insuusyurui[1000] = {};
//ll insuukazu[1000] = {};
//ll memo[4000] = {};
//ll memo2[4000] = {};
//cin >> n;
//cin >> m;
//a = 2;
//// √n ≧ a ( n ≧ a * a ) の間ループ処理
//while (n >= a * a) {
//	// a で割り切れたら、a は素因数
//	// そして、割られる数を a で割る
//	// a で割り切れなかったら、 a を 1 増加させる
//	if (n % a == 0) {
//		printf("%d * ", a);
//		insuukazu[c]++;
//		n /= a;
//	}
//	else {
//		a++;
//		//if (insuukazu[c] != 0)
//		{
//			c++;
//			//cout << c << endl;
//
//		}
//	}
//}
//printf("%d\n", n);
//for (int i = 0; i < c; i++)
//{
//	//cout << insuukazu[i] << endl;
//}
//
//cout << "Yes" << endl;

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

int main(){
  long long num;
  long long kekka = 100;
  long long cnt = 0;
  cin >> num;
  
  while(true){
    kekka = kekka *1.01;
    cnt++;
    
    if(kekka >= num) break;
  }
  
  cout << cnt;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
 
int main() {
  int H,N,sum,x;
cin>>H>>N;
sum=0;
for(int i=1;i<=N;i++){
  cin>>x;
  sum=sum+x;
}
if(H-sum<=0){
  cout<<"Yes";
}
else{
  cout<<"No";
}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<math.h>
using namespace std;

int main(){
 int n, m, x;
 cin>>n>>m>>x;
 vector<int> a(m);
 int temp=0, temp2=0;
 for(int i=0; i<m; i++){
  cin>>a[i];
  if(a[i]<x)temp++;
  else temp2++;
 }
 cout<<min(temp, temp2)<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int n; cin>>n;
    priority_queue<double, vector<double>, greater<double>> que;
    for(int i=0; i<n; i++){
        double v; cin>>v;
        que.emplace(v);
    }

    while(que.size() != 1){
        double v1 = que.top(); que.pop();
        double v2 = que.top(); que.pop();

        que.emplace((v1 + v2) / 2);
    }

    printf("%.10f\n", que.top());
}

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

int main(){
    ll n;
    cin>>n;
    if(n<105){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0;
    for(ll i=3;i<=n;i+=2){
        ll flag=0;
        for(ll j=1;j*j<i;j+=2){
            if(i%j==0){
                flag++;
            }
        }
        if(flag==4){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N = int(input())

prev_B = 0
back_A = 0
AB_num = 0
back_A_prev_B = 0
for i in range(N):
    s = input()
    if s[0] == "B":
        prev_B += 1
    if s[len(s)-1] == "A":
        back_A += 1
    if s[0] == "B" and s[len(s)-1] == "A":
        back_A_prev_B += 1
    for j in range(len(s)-1):
        if s[j] == "A" and s[j+1] == "B":
            AB_num += 1

if back_A_prev_B == prev_B and back_A_prev_B == back_A and back_A_prev_B != 0:
    print(AB_num + min(prev_B-1, back_A-1))
else:
    print(AB_num + min(prev_B, back_A))


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

int main(){
  int n;
  cin >> n;
  if ((n%10==2)||(n%10==4)||(n%10==5)||(n%10==7)||(n%10==9)) cout << "hon" << endl;
  else if ((n%10==0)||(n%10==1)||(n%10==6)||(n%10==8))  cout << "pon" << endl;
  else cout << "bon" << endl;
}



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

int main(){
  
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int c=0;
  int d=0;
  
  for(int i=0;i<N;i++){
    if(a.at(i)%2==0){
      c++;
      if(a.at(i)%3==0||a.at(i)%5==0){
        //cout<<a.at(i)<<endl;
        d++;
      }
    }
  }
  if(c==d){
    cout<<"APPROVED";
  }
  else{
    cout<<"DENIED";
  }
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int k,s;cin>>k>>s;
  int count=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(s-i-j>=0 && s-i-j<=k){
        count++;
      }
    }
  }
  P(count);
  return 0;
}


Measured memory_bytes: 256
//Problem *
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int dp[N],a[N],n,k;

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=2;i<=n;i++){
		dp[i]=1000000007;
		for(int j=1;j<=k&&j<i;j++)dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 1024
// AOJ DSL_2_E Range Add Query (RAQ)
// 2018.5.18 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define MAX_N 100005

int s, t, x, ans;

typedef struct { int l, r, w, f; } NODE;
NODE node[1<<19];

void segTree(int k, int l, int r) 
{
	int m;

	node[k].l = l, node[k].r = r;
	if (node[k].l == node[k].r) return;
	m = (l + r) >> 1;
    segTree( k << 1, l, m);
    segTree((k << 1) | 1, m+1, r);
}

void down(int k) 
{
    node[ k << 1     ].f += node[k].f;
    node[(k << 1) | 1].f += node[k].f;
    node[ k << 1     ].w += node[k].f * (node[ k << 1     ].r - node[ k << 1     ].l + 1);
    node[(k << 1) | 1].w += node[k].f * (node[(k << 1) | 1].r - node[(k << 1) | 1].l + 1);
    node[k].f = 0;
}

void ask_point(int k)
{
	int m;

    if (node[k].l == node[k].r) {
        ans = node[k].w;
        return;
    }
    if (node[k].f) down(k);
    m = (node[k].l + node[k].r) >> 1;
    if (x <= m) ask_point(k << 1);
    else ask_point((k << 1) | 1);
}

void change_point(int k) 
{
	int m;

    if (node[k].l == node[k].r) {
        node[k].w += x;
        return;
    }
    if (node[k].f) down(k);
    m = (node[k].l + node[k].r) >> 1;
    if (s <= m) change_point(k << 1);
    else change_point((k << 1) | 1);
    node[k].w = node[k << 1].w + node[(k << 1) | 1].w;
}

void ask_interval(int k)
{
	int m;

    if (node[k].l >= s && node[k].r <= t) {
        ans += node[k].w;
        return;
    }
    if (node[k].f) down(k);
    m = (node[k].l + node[k].r) >> 1;
    if (s <= m) ask_interval(k << 1);
    if (m < t) ask_interval((k << 1) | 1);
}

void change_interval(int k) 
{
	int m;

	if (node[k].l >= s && node[k].r <= t) {
        node[k].w += (node[k].r - node[k].l + 1) * x;
        node[k].f += x;
        return;
    }
    if (node[k].f) down(k);
    m = (node[k].l + node[k].r) >> 1;
    if (s <= m) change_interval(k << 1);
    if (m < t) change_interval((k << 1) | 1);
    node[k].w = node[k << 1].w + node[(k << 1) | 1].w;
}

int main()
{
	int n, q, op;

	n = in();
    segTree(1, 1, n);

	q = in();
	while (q--) {
		op = gc() & 1, gc();
		if (op) {
			x = in();
			ask_point(1);
			out(ans);
		} else {
			s = in(), t = in(), x = in();
			if (s == t) change_point(1);
			else change_interval(1);
		}
	}
	return 0;
}



Measured memory_bytes: 5704
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int step(string S, int now, int M){
    if(now <= M){return now;}
    int i;
    FOR(i,now-M,now){
        if(S[i]=='0'){return now-i;}
    }
    return -1;
}
  
int main()
{
  int i;
  int N,M; cin >> N >> M;
  string S; cin >> S;
  int ans[100000]={-1};
  int idx = 0;
  int now = N;
  while(now > 0){
      int tmp = step(S,now,M);
      if(tmp == -1){cout << -1 << endl; return 0;}
      ans[idx] = tmp; idx++;
      now -= tmp;
  }
  
  for(i=99999;i>=0;i--){
      if(ans[i]>0){
          cout << ans[i];
          if(i!=0){cout << " ";}
    }
  }

  return 0;
}


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

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout); 
    #endif
    
    fastio(); 

    // int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int X, Y;
    cin >> X >> Y;
    string ans;
    bool isPossible = false;

    if ((4 * X - Y) >= 0) 
    {
        if ((4 * X - Y) <= 2 * X)
        {
            if (not((4 * X - Y) & 1)) isPossible = true;
        }
    } 

    ans = (isPossible)? "Yes": "No";
    cout << ans << "\n"; 
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

long m[5];

int main() {
    int n;
    string s;
    cin >> n;
    REP(i,n) {
        cin >> s;
        if (s[0] == 'M') m[0]++;
        if (s[0] == 'A') m[1]++;
        if (s[0] == 'R') m[2]++;
        if (s[0] == 'C') m[3]++;
        if (s[0] == 'H') m[4]++;
    }
    long ans = 0;
    REP(i,5) {
        REPI(j,i+1,5) {
            REPI(k,j+1,5) {
                ans += m[i] * m[j] * m[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}
int main()
{
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    cout << fixed << setprecision(6);

    int n;
    cin >> n;
    vector<pair<int, int>> vp;

    for (int i = 0; i < n; ++i)
    {
        int a, v;
        cin >> a >> v;
        vp.push_back({v, a});
    }
    sort(vp.rbegin(), vp.rend());

    if (n == 1)
    {
        cout << vp[0].second << " " << vp[0].first << endl;
    }
    else
    {
        int maxV = vp[0].first;
        int idx = vp[0].second;
        for (int i = 0; i < n; ++i)
        {
            if (maxV != vp[i].first)
            {
                break;
            }
            idx = vp[i].second;
        }
        cout << idx << " " << maxV << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

int main()
{
    int k,n;

    cin>>k>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> distance(n);
    sort(a.begin(),a.end());

    distance[0]=((a[n-1]-a[0]<k-a[n-1]+a[1])?(a[n-1]-a[0]):(k-a[n-1]+a[0]));
    int max=distance[0];
    for(int i=0;i<a.size()-1;i++){
        distance[i+1]=a[i+1]-a[i];
        if(distance[i+1]>max)max=distance[i+1];
    }

    int sum=accumulate(distance.begin(),distance.end(),0);
    
    cout<<sum-max;




    //for(int i=0;i<a.size();i++)cout<<distance[i]<<" ";
}






Measured memory_bytes: 1792
S = input()
if S == "SUN" :
	answer = 7
elif S == "MON" :
	answer = 6
elif S == "TUE" :
	answer = 5
elif S == "WED" :
	answer = 4
elif S == "THU" :
	answer = 3
elif S == "FRI" :
	answer = 2
elif S == "SAT" :
	answer = 1
 
print(answer)

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>


using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<long long> as(3*N);
    for (auto &a : as) {
        cin >> a;
    }

    sort(as.begin(), as.end());
    decltype(as)::value_type ret = 0ULL;
    
    for (int i=0; i<N; ++i) {
        int j = 3*N - 2*(i+1);
        ret += as[j];
    }

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a;
  cin >> n >> a;
  long long ans = n;
  long long b = n - a;
  if (a < b) {
    swap(a, b);
  }
  while (b) {
    long long q = a / b;
    ans += 2 * q * b;
    a %= b;
    swap(a, b);
  }
  ans -= a;
  cout << ans << '\n';
  return 0;
}

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

#define N ((int)1e5 + 1)
#define forn(i,x,y) for(int i = int(x); i<int(y); i++)
#define debug(x) cerr << #x << " == " << (x) << '\n';
#define all(V) V.begin(), V.end()

template<typename T> ostream &operator<<(ostream &out, const pair<T, T> &P){ out << P.first << ' ' << P.second; return out; }
template<typename T> ostream &operator<<(ostream &out, const vector<T> &V){ for(int i = 0; i<V.size(); ++i) out << V[i] << ' '; return out; }
template<typename T> istream &operator>>(istream &in, vector<T> &V){ for(T &i : V) in >> i; return in; }
template<typename T> istream &operator>>(istream &in, pair<T,T> &P){ in >> P.first >> P.second; return in; }

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

    ll n; cin >> n;
    if(n % 2 == 1) {
        cout << "0\n";
        exit(0);
    }

    ll ans = 0;
    ll p = 10LL;
    while(p <= n) {
        ans += n / p;
        if(p > LLONG_MAX / 5) break;
        p *= 5LL;
    }

    cout << ans << '\n';

    return 0;
}

/* don't forget to check:
   int overflow
   min/max cases (n = 1)
   printing index of sorted array
   limits for ans (start with inf)
 */


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

bool compare(string a,string b){

   if(a[0]==b[0]){
        for(int i=1;a[i];i++){
            if(a[i]==b[i])
                continue;
            else
                return a[i]<b[i];
        }
        return a<b;
   }
   else
        return a[0] < b[0];
}

int main()
{

    int n,k;
    cin>>n>>k;
    vector<string>v;
    string str;
    for(int i=0;i<n;i++){
        cin>>str;
        v.push_back(str);
    }

    sort(v.begin(),v.end(),compare);

    for(int i=0;i<n;i++){
        cout<<v[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define Abra_Ka_Dabra ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double EPS = 1e-9;


int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	Abra_Ka_Dabra

	string x;
	cin >> x;
	cout << string(x.size(), 'x') << "\n";

	return 0;
}



Measured memory_bytes: 3584
/*
	设 f[i] 为点 i 可以往上传的值
	设一个方程发现在某个点配对的个数和上传的个数是固定的
*/
#include <iostream>
#include <cstdio>
#include <vector>
#define N 100005

using namespace std;

int n;
int a[N], f[N];

vector<int> g[N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
void dfs(int u, int fa) {
	int S = g[u].size();
	if(S == 1) { return f[u] = a[u], void(); }
	int Max = 0, sum = 0;
	for(int i = 0; i < S; ++i) {
		int v = g[u][i];
		if(v == fa) continue;
		dfs(v, u);
		sum += f[v];
		Max = max(Max, f[v]);
	}
	/*
		A : 配对的个数, B : 上传的个数
	    { A + B = a[u];
	    { 2 * A + B = sum;
	*/
	int A = sum - a[u], B = a[u] - A;
	if(A < 0 || B < 0 || A > min(sum - Max, sum / 2)) {
		puts("NO");
		exit(0);
	}
	f[u] = B;
	return;
}

int main() {
	read(n);
	for(int i = 1; i <= n; ++i) read(a[i]);
	for(int i = 1, u, v; i < n; ++i) {
		read(u), read(v);
		g[u].push_back(v), g[v].push_back(u);
	}
	if(n == 2) {
		puts(a[1] == a[2] ? "YES" : "NO");
		return 0;
	}
	for(int i = 1; i <= n; ++i) 
		if(g[i].size() != 1) {
			dfs(i, 0);
			puts(f[i] ? "NO" : "YES");
			break;
		}
	return 0;
}

Measured memory_bytes: 14464
#include <iostream>
using namespace std;
//さいあくだ…
int main() {
    char x,y;
    int xx,yy;
    cin>>x>>y;
    if(x=='A')xx=10;
    else if(x=='B')xx=11;
    else if(x=='C')xx=12;
    else if(x=='D')xx=13;
    else if(x=='E')xx=14;
    else if(x=='F')xx=15;
    if(y=='A')yy=10;
    else if(y=='B')yy=11;
    else if(y=='C')yy=12;
    else if(y=='D')yy=13;
    else if(y=='E')yy=14;
    else if(y=='F')yy=15;
    
    if(xx>yy)cout<<'>'<<endl;
    else if(xx==yy)cout<<'='<<endl;
    else if(xx<yy)cout<<'<'<<endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];
ll ifact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++) fact[i] = (fact[i-1] * i) % MOD;
  ifact[maxf]=modpow(fact[maxf],MOD-2);
  for(ll i=maxf; i>=1; i--) ifact[i-1] = (ifact[i] * i) % MOD;
}

ll comb(ll n, ll r){
  if(n<r || n<0 || r<0) return 0;
  if(fact[0] == 0) fact_init();
  return ((fact[n] * ifact[n-r]) % MOD * ifact[r]) % MOD;
}

ll naive_comb(ll n, ll r){
  ll res = 1;
  for (ll i = n; i > n - r; i--) res = res * i % MOD;
  for (ll i = 1; i <= r; i++) res = (res * modpow(i, MOD-2)) % MOD;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  reverse(all(s));
  ll n=s.size();
  vll sum(n+1);
  ll x=1;
  rep(i,n){
    ll num=s[i]-'0';
    sum[i+1]=(sum[i]+num*x)%2019;
    (x*=10)%=2019;
  }
  map<ll,ll> m;
  rep(i,n+1){
    m[sum[i]]++;
  }
  
  ll ans=0;
  for(auto e: m){
    ans+=(e.second-1)*e.second/2;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define daman ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
int main(){
	int a,b;
	cin>>a>>b;
	cout<<a*b<<"\n";
}

Measured memory_bytes: 3592
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,a,b = ips()

ans = (n // (a+b))*a
ans+= min(n%(a+b),a)
print(ans)


Measured memory_bytes: 5588
#include <cmath>
#include <iostream>
const int N=1001;
int main(){
	double A[N]={0},a=0,b;
	for(int i=1;i<N;i++){
		A[i]=a;
		a+=atan2(1,sqrt(i));
	}
	int n;
	while(std::cin>>n,n+1){
		b=sqrt(n);
		std::cout<<b*cos(A[n])<<"\n"<<b*sin(A[n])<<"\n";
	}
}

Measured memory_bytes: 1312
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
#include <thread>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, K; cin >> N >> K;
    vl H(N); rep(i, N) cin >> H[i];
    ll cnt = 0;
    rep(i, N){
        if(H[i] >= K) cnt++;
    }
    cout << cnt << endstr;
    return 0;
}


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

int main (){
    int a, b, c;
    cin>>a>>b>>c;
    
    if(a==b){
        cout<<c<<endl;
    }
    else if(a==c){
        cout<<b<<endl;
    }
    else{
        cout<<a<<endl;
    }
}

    

Measured memory_bytes: 256
import numpy as np
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
a=np.array(A)
b=np.array(B)
count=0
for i in range(N):
    if np.inner(a[i],b)+C>0:
        count+=1
print(count)

Measured memory_bytes: 12424
n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for i in range(m):
    a,b = map(int,input().split())
    ans[a-1] += 1
    ans[b-1] += 1
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.equals("zyxwvutsrqponmlkjihgfedcba")) {
			System.out.println("-1");
			return;
		}
		String[] a = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
		String[] t = s.split("");
		if (s.length() == 26) {
			for (int i = 24; i >= 0; i--) {
				for (int j = 0; j < 26; j++) {
					boolean exist = false;
					for (int k = 0; k < i; k++) {
						if (a[j].equals(t[k])) {
							exist = true;
							break;
						}
					}
					if (!exist) {
						if (s.charAt(i) < a[j].charAt(0)) {
							System.out.println(s.substring(0, i) + a[j]);
							return;
						}
					}
				}
			}
		}
		for (int i = 0; i < a.length; i++) {
			boolean exist = false;
			for (int j = 0; j < t.length; j++) {
				if (a[i].equals(t[j])) {
					exist = true;
					break;
				}
			}
			if (!exist) {
				System.out.println(s + a[i]);
				return;
			}
		}
	}
}

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

int main() {
  ll n;
  cin>>n;
  vector<map<char,ll>> ana(n);
  map<map<char,ll>,ll> koromo;
  rep(i,n){
    string s;
    cin>>s;
    rep(j,10){
      ana[i][s[j]]++;
    }
    koromo[ana[i]]++;
  }
  ll ans=0;
  for(auto x:koromo){
    ans+=x.second*(x.second-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 119808
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[100009][2];

int main(){
  string s;
  cin>>s;
  int n=s.size();
  dp[0][0]=1;
  rep(i,n){
    {
      // a+b == 0
      if(s[i]=='0'){
        dp[i+1][0]=dp[i][0];
        dp[i+1][1]=dp[i][1];
      }
      else{
        dp[i+1][1]=dp[i][0]+dp[i][1];
      }
    }
    {
      // a+b == 1
      if(s[i]=='0'){
        dp[i+1][1]+=dp[i][1]*2;
      }
      else{
        dp[i+1][0]+=dp[i][0]*2;
        dp[i+1][1]+=dp[i][1]*2;
      }
    }
  }
  mint ans=dp[n][0]+dp[n][1];
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 2048
#include <stdio.h>
long long h, w, ans;
int main() {
	scanf("%lld%lld", &h, &w);
	if (h == 1 || w == 1) {
		printf("%lld\n", 1);
		return 0;
	}
	ans = h * w;
	if (h % 2 && w % 2)ans++;
	printf("%lld\n", ans / 2);
}

Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect_left

def main():
    N, *A = map(int, open(0).read().split())

    A = [0] + list(accumulate(A))

    ans = float("inf")
    for i in range(2, N - 1):
        lm = A[i] // 2
        l = bisect_left(A, lm)
        if abs(A[l - 1] - lm) < abs(A[l] - lm):
            l -= 1

        rm = (A[i] + A[N]) // 2
        r = bisect_left(A, rm)
        if abs(A[r - 1] - rm) < abs(A[r] - rm):
            r -= 1

        P = A[l]
        Q = A[i] - A[l]
        R = A[r] - A[i]
        S = A[N] - A[r]

        ans = min(ans, max(P, Q, R, S) - min(P, Q, R, S))

    print(ans)

main()


Measured memory_bytes: 24856
#![allow(non_snake_case,unused_imports,dead_code)]

use std::str::FromStr;
use std::collections::{HashMap,HashSet,VecDeque,BinaryHeap};
use std::cmp::{max,min,Reverse,Ordering};
use std::io::Read;
use std::time::{Duration, Instant};
use rand::Rng;
 
use proconio::input;
use proconio::marker::{Chars,Usize1,Isize1};

fn main() {
    input!{
        K:usize,
    }

    println!("{}",vec!["ACL";K].join(""));

}



Measured memory_bytes: 2072